nmtjs 0.16.0-beta.9 → 0.16.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/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/entrypoints/worker.js +9 -9
- package/dist/entrypoints/worker.js.map +1 -1
- package/dist/index.d.ts +14 -11
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime/application/index.d.ts +1 -5
- package/dist/runtime/application/index.js +1 -5
- package/dist/runtime/application/index.js.map +1 -1
- package/dist/runtime/enums.d.ts +1 -12
- package/dist/runtime/enums.js +1 -14
- package/dist/runtime/enums.js.map +1 -1
- package/dist/runtime/hooks.d.ts +1 -4
- package/dist/runtime/hooks.js +1 -3
- package/dist/runtime/hooks.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -3
- package/dist/runtime/index.js +1 -3
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/injectables.d.ts +3 -3
- package/dist/runtime/jobs/job.d.ts +1 -2
- package/dist/runtime/jobs/job.js.map +1 -1
- package/dist/runtime/jobs/router.d.ts +2 -5
- package/dist/runtime/jobs/router.js +2 -3
- package/dist/runtime/jobs/router.js.map +1 -1
- package/dist/runtime/jobs/runner.d.ts +1 -1
- package/dist/runtime/jobs/runner.js +1 -1
- package/dist/runtime/jobs/runner.js.map +1 -1
- package/dist/runtime/jobs/types.d.ts +1 -1
- package/dist/runtime/metrics/metric.d.ts +2 -2
- package/dist/runtime/metrics/metric.js +1 -1
- package/dist/runtime/metrics/metric.js.map +1 -1
- package/dist/runtime/metrics/registry.d.ts +3 -3
- package/dist/runtime/metrics/registry.js +1 -1
- package/dist/runtime/metrics/registry.js.map +1 -1
- package/dist/runtime/metrics/server.js +1 -1
- package/dist/runtime/metrics/server.js.map +1 -1
- package/dist/runtime/plugin.d.ts +2 -8
- package/dist/runtime/plugin.js +1 -3
- package/dist/runtime/plugin.js.map +1 -1
- package/dist/runtime/runtime.d.ts +2 -2
- package/dist/runtime/runtime.js +1 -2
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/server/applications.js +3 -0
- package/dist/runtime/server/applications.js.map +1 -1
- package/dist/runtime/server/config.d.ts +15 -12
- package/dist/runtime/server/config.js.map +1 -1
- package/dist/runtime/server/jobs.d.ts +6 -7
- package/dist/runtime/server/jobs.js +44 -30
- package/dist/runtime/server/jobs.js.map +1 -1
- package/dist/runtime/subscription/redis.d.ts +1 -1
- package/dist/runtime/subscription/redis.js.map +1 -1
- package/dist/runtime/types.d.ts +3 -11
- package/dist/runtime/workers/application.d.ts +15 -33
- package/dist/runtime/workers/application.js +46 -139
- package/dist/runtime/workers/application.js.map +1 -1
- package/dist/runtime/workers/job.js +2 -1
- package/dist/runtime/workers/job.js.map +1 -1
- package/dist/vite/server.js +1 -1
- package/dist/vite/server.js.map +1 -1
- package/package.json +19 -14
- package/src/cli.ts +2 -3
- package/src/entrypoints/worker.ts +11 -9
- package/src/index.ts +12 -5
- package/src/runtime/application/index.ts +1 -5
- package/src/runtime/enums.ts +2 -14
- package/src/runtime/hooks.ts +1 -5
- package/src/runtime/index.ts +2 -3
- package/src/runtime/injectables.ts +2 -2
- package/src/runtime/jobs/job.ts +1 -2
- package/src/runtime/jobs/router.ts +12 -15
- package/src/runtime/jobs/runner.ts +2 -2
- package/src/runtime/jobs/types.ts +1 -1
- package/src/runtime/metrics/metric.ts +2 -2
- package/src/runtime/metrics/registry.ts +5 -1
- package/src/runtime/metrics/server.ts +1 -1
- package/src/runtime/plugin.ts +2 -13
- package/src/runtime/runtime.ts +2 -4
- package/src/runtime/server/applications.ts +6 -0
- package/src/runtime/server/config.ts +27 -21
- package/src/runtime/server/jobs.ts +58 -34
- package/src/runtime/subscription/redis.ts +1 -1
- package/src/runtime/types.ts +3 -12
- package/src/runtime/workers/application.ts +76 -160
- package/src/runtime/workers/job.ts +3 -6
- package/src/vite/server.ts +1 -1
- package/dist/runtime/application/api/api.d.ts +0 -55
- package/dist/runtime/application/api/api.js +0 -252
- package/dist/runtime/application/api/api.js.map +0 -1
- package/dist/runtime/application/api/config.d.ts +0 -14
- package/dist/runtime/application/api/config.js +0 -6
- package/dist/runtime/application/api/config.js.map +0 -1
- package/dist/runtime/application/api/constants.d.ts +0 -14
- package/dist/runtime/application/api/constants.js +0 -8
- package/dist/runtime/application/api/constants.js.map +0 -1
- package/dist/runtime/application/api/filters.d.ts +0 -14
- package/dist/runtime/application/api/filters.js +0 -11
- package/dist/runtime/application/api/filters.js.map +0 -1
- package/dist/runtime/application/api/guards.d.ts +0 -15
- package/dist/runtime/application/api/guards.js +0 -8
- package/dist/runtime/application/api/guards.js.map +0 -1
- package/dist/runtime/application/api/index.d.ts +0 -23
- package/dist/runtime/application/api/index.js +0 -17
- package/dist/runtime/application/api/index.js.map +0 -1
- package/dist/runtime/application/api/logging.d.ts +0 -14
- package/dist/runtime/application/api/logging.js +0 -77
- package/dist/runtime/application/api/logging.js.map +0 -1
- package/dist/runtime/application/api/meta.d.ts +0 -21
- package/dist/runtime/application/api/meta.js +0 -2
- package/dist/runtime/application/api/meta.js.map +0 -1
- package/dist/runtime/application/api/middlewares.d.ts +0 -14
- package/dist/runtime/application/api/middlewares.js +0 -12
- package/dist/runtime/application/api/middlewares.js.map +0 -1
- package/dist/runtime/application/api/procedure.d.ts +0 -71
- package/dist/runtime/application/api/procedure.js +0 -41
- package/dist/runtime/application/api/procedure.js.map +0 -1
- package/dist/runtime/application/api/router.d.ts +0 -93
- package/dist/runtime/application/api/router.js +0 -55
- package/dist/runtime/application/api/router.js.map +0 -1
- package/dist/runtime/application/api/types.d.ts +0 -38
- package/dist/runtime/application/api/types.js +0 -2
- package/dist/runtime/application/api/types.js.map +0 -1
- package/dist/runtime/application/config.d.ts +0 -28
- package/dist/runtime/application/config.js +0 -25
- package/dist/runtime/application/config.js.map +0 -1
- package/dist/runtime/application/constants.d.ts +0 -2
- package/dist/runtime/application/constants.js +0 -2
- package/dist/runtime/application/constants.js.map +0 -1
- package/dist/runtime/application/hook.d.ts +0 -19
- package/dist/runtime/application/hook.js +0 -11
- package/dist/runtime/application/hook.js.map +0 -1
- package/dist/runtime/application/hooks.d.ts +0 -3
- package/dist/runtime/application/hooks.js +0 -4
- package/dist/runtime/application/hooks.js.map +0 -1
- package/src/runtime/application/api/api.ts +0 -406
- package/src/runtime/application/api/config.ts +0 -18
- package/src/runtime/application/api/constants.ts +0 -22
- package/src/runtime/application/api/filters.ts +0 -39
- package/src/runtime/application/api/guards.ts +0 -33
- package/src/runtime/application/api/index.ts +0 -69
- package/src/runtime/application/api/logging.ts +0 -110
- package/src/runtime/application/api/meta.ts +0 -37
- package/src/runtime/application/api/middlewares.ts +0 -37
- package/src/runtime/application/api/procedure.ts +0 -224
- package/src/runtime/application/api/router.ts +0 -247
- package/src/runtime/application/api/types.ts +0 -138
- package/src/runtime/application/config.ts +0 -82
- package/src/runtime/application/constants.ts +0 -4
- package/src/runtime/application/hook.ts +0 -51
- package/src/runtime/application/hooks.ts +0 -3
|
@@ -1,217 +1,133 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ApplicationHost,
|
|
3
|
+
ApplicationHostDefinition,
|
|
4
|
+
ApplicationHostOptions,
|
|
5
|
+
ApplicationResolvedProcedure,
|
|
6
|
+
ApplicationTransport,
|
|
7
|
+
NeemataApplication,
|
|
8
|
+
TransportOptionsOf,
|
|
9
|
+
} from '@nmtjs/application'
|
|
10
|
+
import type { Gateway, GatewayOptions } from '@nmtjs/gateway'
|
|
11
|
+
import { createApplicationHost, LifecycleHook } from '@nmtjs/application'
|
|
4
12
|
import { JsonFormat } from '@nmtjs/json-format/server'
|
|
5
13
|
import { MsgpackFormat } from '@nmtjs/msgpack-format/server'
|
|
6
14
|
import { ProtocolFormats } from '@nmtjs/protocol/server'
|
|
7
15
|
|
|
8
|
-
import type {
|
|
9
|
-
import
|
|
10
|
-
AnyFilter,
|
|
11
|
-
AnyGuard,
|
|
12
|
-
AnyMiddleware,
|
|
13
|
-
AnyProcedure,
|
|
14
|
-
AnyRouter,
|
|
15
|
-
kDefaultProcedure as kDefaultProcedureKey,
|
|
16
|
-
} from '../application/index.ts'
|
|
17
|
-
import type { ServerConfig } from '../server/config.ts'
|
|
18
|
-
import { ApplicationApi } from '../application/api/api.ts'
|
|
19
|
-
import { ApplicationHooks } from '../application/hooks.ts'
|
|
20
|
-
import {
|
|
21
|
-
isProcedure,
|
|
22
|
-
isRootRouter,
|
|
23
|
-
isRouter,
|
|
24
|
-
kDefaultProcedure,
|
|
25
|
-
kRootRouter,
|
|
26
|
-
} from '../application/index.ts'
|
|
27
|
-
import { LifecycleHook, WorkerType } from '../enums.ts'
|
|
16
|
+
import type { ServerApplicationConfig, ServerConfig } from '../server/config.ts'
|
|
17
|
+
import { WorkerType } from '../enums.ts'
|
|
28
18
|
import { BaseWorkerRuntime } from './base.ts'
|
|
29
19
|
|
|
30
20
|
export interface ApplicationWorkerRuntimeOptions {
|
|
31
21
|
name: string
|
|
32
22
|
path: string
|
|
33
|
-
transports:
|
|
23
|
+
transports: ServerApplicationConfig['threads'][number]
|
|
34
24
|
}
|
|
35
25
|
|
|
36
26
|
export class ApplicationWorkerRuntime extends BaseWorkerRuntime {
|
|
37
|
-
|
|
38
|
-
applicationHooks!: ApplicationHooks
|
|
39
|
-
gateway!: Gateway
|
|
40
|
-
transports!: GatewayOptions['transports']
|
|
41
|
-
|
|
42
|
-
routers = new Map<string | kRootRouter, AnyRouter>()
|
|
43
|
-
procedures = new Map<
|
|
44
|
-
string | kDefaultProcedureKey,
|
|
45
|
-
{ procedure: AnyProcedure; path: AnyRouter[] }
|
|
46
|
-
>()
|
|
47
|
-
filters = new Set<AnyFilter>()
|
|
48
|
-
middlewares = new Set<AnyMiddleware>()
|
|
49
|
-
guards = new Set<AnyGuard>()
|
|
27
|
+
host!: ApplicationHost
|
|
50
28
|
|
|
51
29
|
constructor(
|
|
52
30
|
readonly config: ServerConfig,
|
|
53
31
|
readonly runtimeOptions: ApplicationWorkerRuntimeOptions,
|
|
54
|
-
protected
|
|
32
|
+
protected hostDefinition: ApplicationHostDefinition,
|
|
55
33
|
) {
|
|
56
34
|
super(
|
|
57
35
|
config,
|
|
58
36
|
{
|
|
59
37
|
logger: config.logger,
|
|
60
38
|
name: `Worker ${runtimeOptions.name}`,
|
|
61
|
-
plugins:
|
|
39
|
+
plugins: [],
|
|
62
40
|
},
|
|
63
41
|
WorkerType.Application,
|
|
64
42
|
)
|
|
43
|
+
}
|
|
65
44
|
|
|
66
|
-
|
|
45
|
+
get application(): NeemataApplication {
|
|
46
|
+
return this.host.application
|
|
47
|
+
}
|
|
67
48
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
container: this.container,
|
|
71
|
-
logger: this.logger,
|
|
72
|
-
meta: this.appConfig.meta,
|
|
73
|
-
filters: this.filters,
|
|
74
|
-
middlewares: this.middlewares,
|
|
75
|
-
guards: this.guards,
|
|
76
|
-
procedures: this.procedures,
|
|
77
|
-
})
|
|
49
|
+
get api() {
|
|
50
|
+
return this.application.api
|
|
78
51
|
}
|
|
79
52
|
|
|
80
|
-
|
|
81
|
-
|
|
53
|
+
get applicationHooks() {
|
|
54
|
+
return this.application.applicationHooks
|
|
55
|
+
}
|
|
82
56
|
|
|
83
|
-
|
|
57
|
+
get gateway(): Gateway<ApplicationResolvedProcedure> {
|
|
58
|
+
return this.host.gateway
|
|
59
|
+
}
|
|
84
60
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.transports[key] = { transport: await factory(options), proxyable }
|
|
89
|
-
}
|
|
61
|
+
get transports(): GatewayOptions<ApplicationResolvedProcedure>['transports'] {
|
|
62
|
+
return this.host.transports
|
|
63
|
+
}
|
|
90
64
|
|
|
91
|
-
|
|
92
|
-
|
|
65
|
+
async start() {
|
|
66
|
+
await this.initialize()
|
|
67
|
+
this.host = createApplicationHost(this.hostDefinition.application, {
|
|
68
|
+
name: this.runtimeOptions.name,
|
|
93
69
|
logger: this.logger,
|
|
94
70
|
container: this.container,
|
|
95
|
-
hooks: this.lifecycleHooks,
|
|
96
71
|
formats: new ProtocolFormats([new JsonFormat(), new MsgpackFormat()]),
|
|
97
|
-
|
|
98
|
-
api: this.api,
|
|
99
|
-
identity: this.appConfig.identity,
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
return await this.gateway.start().finally(async () => {
|
|
103
|
-
await this.lifecycleHooks.callHook(LifecycleHook.Start)
|
|
72
|
+
...this.resolveHostOptions(),
|
|
104
73
|
})
|
|
74
|
+
return this.host.start()
|
|
105
75
|
}
|
|
106
76
|
|
|
107
77
|
async stop() {
|
|
108
|
-
await this.
|
|
78
|
+
await this.host.stop()
|
|
109
79
|
await this.dispose()
|
|
110
80
|
await this.lifecycleHooks.callHook(LifecycleHook.Stop)
|
|
111
81
|
}
|
|
112
82
|
|
|
113
|
-
async reload(
|
|
114
|
-
|
|
115
|
-
this.
|
|
116
|
-
this.plugins = appConfig.plugins
|
|
117
|
-
await this.initialize()
|
|
118
|
-
this.gateway.options.identity =
|
|
119
|
-
this.appConfig.identity ?? this.gateway.options.identity
|
|
120
|
-
await this.gateway.reload()
|
|
83
|
+
async reload(hostDefinition: ApplicationHostDefinition): Promise<void> {
|
|
84
|
+
this.hostDefinition = hostDefinition
|
|
85
|
+
await this.host.reloadApplication(hostDefinition.application)
|
|
121
86
|
}
|
|
122
87
|
|
|
123
|
-
|
|
124
|
-
this.registerApi()
|
|
125
|
-
this.lifecycleHooks.addHooks(this.appConfig.lifecycleHooks)
|
|
126
|
-
await super.initialize()
|
|
127
|
-
}
|
|
88
|
+
protected *_dependents() {}
|
|
128
89
|
|
|
129
|
-
protected
|
|
130
|
-
|
|
90
|
+
protected resolveHostOptions(): Pick<
|
|
91
|
+
ApplicationHostOptions,
|
|
92
|
+
'transports' | 'gateway' | 'identity'
|
|
93
|
+
> {
|
|
94
|
+
const config = this.config.applications[
|
|
95
|
+
this.runtimeOptions.name
|
|
96
|
+
] as ServerApplicationConfig
|
|
131
97
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
})
|
|
98
|
+
if (!config) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`Missing server application config: ${this.runtimeOptions.name}`,
|
|
101
|
+
)
|
|
137
102
|
}
|
|
138
|
-
}
|
|
139
103
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
this.routers.clear()
|
|
148
|
-
this.procedures.clear()
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
protected *_dependents(): Generator<Dependant> {
|
|
152
|
-
yield* this.appConfig.filters
|
|
153
|
-
yield* this.appConfig.guards
|
|
154
|
-
yield* this.appConfig.middlewares
|
|
155
|
-
yield* this.appConfig.meta
|
|
156
|
-
yield* this.appConfig.hooks
|
|
157
|
-
for (const router of this.routers.values()) {
|
|
158
|
-
yield* router.meta
|
|
159
|
-
}
|
|
160
|
-
for (const { procedure } of this.procedures.values()) {
|
|
161
|
-
yield procedure
|
|
162
|
-
yield* procedure.meta
|
|
163
|
-
yield* procedure.guards
|
|
164
|
-
yield* procedure.middlewares
|
|
104
|
+
return {
|
|
105
|
+
transports: createHostTransportConfig(
|
|
106
|
+
this.hostDefinition.transports,
|
|
107
|
+
this.runtimeOptions.transports,
|
|
108
|
+
),
|
|
109
|
+
gateway: this.hostDefinition.gateway,
|
|
110
|
+
identity: this.hostDefinition.identity,
|
|
165
111
|
}
|
|
166
112
|
}
|
|
113
|
+
}
|
|
167
114
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
this.routers.set(kRootRouter, router)
|
|
180
|
-
this.registerRouter(router, [])
|
|
181
|
-
|
|
182
|
-
if (router.default) {
|
|
183
|
-
if (!isProcedure(router.default)) {
|
|
184
|
-
throw new Error('Root router default must be a procedure')
|
|
185
|
-
}
|
|
186
|
-
this.procedures.set(kDefaultProcedure, {
|
|
187
|
-
procedure: router.default,
|
|
188
|
-
path: [router],
|
|
189
|
-
})
|
|
115
|
+
function createHostTransportConfig<
|
|
116
|
+
Transports extends Record<string, ApplicationTransport>,
|
|
117
|
+
>(
|
|
118
|
+
transports: Transports,
|
|
119
|
+
options: { [K in keyof Transports]: TransportOptionsOf<Transports[K]> },
|
|
120
|
+
) {
|
|
121
|
+
const config = {} as {
|
|
122
|
+
[K in keyof Transports]: {
|
|
123
|
+
transport: Transports[K]
|
|
124
|
+
options: TransportOptionsOf<Transports[K]>
|
|
190
125
|
}
|
|
191
|
-
|
|
192
|
-
for (const filter of filters) this.filters.add(filter)
|
|
193
|
-
for (const middleware of middlewares) this.middlewares.add(middleware)
|
|
194
|
-
for (const guard of guards) this.guards.add(guard)
|
|
195
126
|
}
|
|
196
127
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (isRouter(route)) {
|
|
200
|
-
const name = route.contract.name
|
|
201
|
-
if (!name) throw new Error('Nested routers must have a name')
|
|
202
|
-
if (this.routers.has(name)) {
|
|
203
|
-
throw new Error(`Router ${String(name)} already registered`)
|
|
204
|
-
}
|
|
205
|
-
this.routers.set(name, route)
|
|
206
|
-
this.registerRouter(route, [...path, router])
|
|
207
|
-
} else if (isProcedure(route)) {
|
|
208
|
-
const name = route.contract.name
|
|
209
|
-
if (!name) throw new Error('Procedures must have a name')
|
|
210
|
-
if (this.procedures.has(name)) {
|
|
211
|
-
throw new Error(`Procedure ${name} already registered`)
|
|
212
|
-
}
|
|
213
|
-
this.procedures.set(name, { procedure: route, path: [...path, router] })
|
|
214
|
-
}
|
|
215
|
-
}
|
|
128
|
+
for (const key in transports) {
|
|
129
|
+
config[key] = { transport: transports[key], options: options[key] }
|
|
216
130
|
}
|
|
131
|
+
|
|
132
|
+
return config
|
|
217
133
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { MessagePort } from 'node:worker_threads'
|
|
2
2
|
|
|
3
|
+
import { LifecycleHook } from '@nmtjs/application'
|
|
3
4
|
import { UnrecoverableError } from 'bullmq'
|
|
4
5
|
|
|
5
|
-
import type { JobWorkerPool } from '../enums.ts'
|
|
6
6
|
import type { JobProgressCheckpoint } from '../jobs/types.ts'
|
|
7
7
|
import type { ServerConfig } from '../server/config.ts'
|
|
8
8
|
import type { ServerPortMessage, ThreadPortMessage } from '../types.ts'
|
|
9
|
-
import {
|
|
9
|
+
import { WorkerType } from '../enums.ts'
|
|
10
10
|
import { jobWorkerPool } from '../injectables.ts'
|
|
11
11
|
import { ApplicationWorkerJobRunner } from '../jobs/runner.ts'
|
|
12
12
|
import { BaseWorkerRuntime } from './base.ts'
|
|
@@ -52,10 +52,7 @@ export class JobWorkerRuntime extends BaseWorkerRuntime {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
this.container.provide(
|
|
56
|
-
jobWorkerPool,
|
|
57
|
-
this.runtimeOptions.poolName as JobWorkerPool,
|
|
58
|
-
)
|
|
55
|
+
this.container.provide(jobWorkerPool, this.runtimeOptions.poolName)
|
|
59
56
|
await super.initialize()
|
|
60
57
|
}
|
|
61
58
|
|
package/src/vite/server.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { ViteConfigOptions } from './config.ts'
|
|
|
7
7
|
// When externalized, Vite's ModuleRunner uses native Node import() which has
|
|
8
8
|
// a separate module cache from Vite's cache, causing the same module to be
|
|
9
9
|
// loaded twice with different object references.
|
|
10
|
-
const noExternalPackages = ['nmtjs', /^@nmtjs
|
|
10
|
+
const noExternalPackages = ['nmtjs', /^@nmtjs\/(?!prom-client$)/]
|
|
11
11
|
|
|
12
12
|
export function createServer(
|
|
13
13
|
options: ViteConfigOptions,
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { AnyMetaBinding, Container, Logger } from '@nmtjs/core';
|
|
2
|
-
import type { GatewayApi, GatewayApiCallOptions, GatewayApiCallResult, GatewayConnection, GatewayResolvedProcedure, GatewayResolveOptions } from '@nmtjs/gateway';
|
|
3
|
-
import { ProtocolError } from '@nmtjs/protocol/server';
|
|
4
|
-
import type { kDefaultProcedure as kDefaultProcedureKey } from './constants.ts';
|
|
5
|
-
import type { AnyFilter } from './filters.ts';
|
|
6
|
-
import type { AnyGuard } from './guards.ts';
|
|
7
|
-
import type { AnyMiddleware } from './middlewares.ts';
|
|
8
|
-
import type { AnyProcedure } from './procedure.ts';
|
|
9
|
-
import type { AnyRouter } from './router.ts';
|
|
10
|
-
export type ApiCallOptions<T extends AnyProcedure = AnyProcedure> = Readonly<{
|
|
11
|
-
callId: string;
|
|
12
|
-
connection: GatewayConnection;
|
|
13
|
-
path: AnyRouter[];
|
|
14
|
-
procedure: T;
|
|
15
|
-
container: Container;
|
|
16
|
-
payload: any;
|
|
17
|
-
signal: AbortSignal;
|
|
18
|
-
}>;
|
|
19
|
-
export type ApiOptions = {
|
|
20
|
-
timeout?: number;
|
|
21
|
-
container: Container;
|
|
22
|
-
logger: Logger;
|
|
23
|
-
procedures: Map<string | kDefaultProcedureKey, {
|
|
24
|
-
procedure: AnyProcedure;
|
|
25
|
-
path: AnyRouter[];
|
|
26
|
-
}>;
|
|
27
|
-
meta: readonly AnyMetaBinding[];
|
|
28
|
-
guards: Set<AnyGuard>;
|
|
29
|
-
middlewares: Set<AnyMiddleware>;
|
|
30
|
-
filters: Set<AnyFilter>;
|
|
31
|
-
};
|
|
32
|
-
export declare class ApiError extends ProtocolError {
|
|
33
|
-
toString(): string;
|
|
34
|
-
}
|
|
35
|
-
export declare class ApplicationApi implements GatewayApi {
|
|
36
|
-
options: ApiOptions;
|
|
37
|
-
constructor(options: ApiOptions);
|
|
38
|
-
find(procedureName: string): {
|
|
39
|
-
procedure: AnyProcedure;
|
|
40
|
-
path: AnyRouter[];
|
|
41
|
-
};
|
|
42
|
-
resolve(options: GatewayResolveOptions): Promise<GatewayResolvedProcedure>;
|
|
43
|
-
call(options: GatewayApiCallOptions): Promise<GatewayApiCallResult>;
|
|
44
|
-
private createProcedureHandler;
|
|
45
|
-
private resolveMetaBindings;
|
|
46
|
-
private applyStaticMetaBindings;
|
|
47
|
-
private applyFactoryMetaBindings;
|
|
48
|
-
private resolveMiddlewares;
|
|
49
|
-
private withTimeout;
|
|
50
|
-
private handleGuards;
|
|
51
|
-
private handleFilters;
|
|
52
|
-
private handleInput;
|
|
53
|
-
private handleIterableOutput;
|
|
54
|
-
private handleOutput;
|
|
55
|
-
}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import { randomUUID } from 'node:crypto';
|
|
3
|
-
import { inspect } from 'node:util';
|
|
4
|
-
import { withTimeout } from '@nmtjs/common';
|
|
5
|
-
import { IsStreamProcedureContract } from '@nmtjs/contract';
|
|
6
|
-
import { getMetaBindingMeta, getStaticMetaValue, isStaticMetaBinding, Scope, } from '@nmtjs/core';
|
|
7
|
-
import { createGatewayStaticMetaView, isAsyncIterable, rpcStreamAbortSignal, } from '@nmtjs/gateway';
|
|
8
|
-
import { ErrorCode } from '@nmtjs/protocol';
|
|
9
|
-
import { ProtocolError } from '@nmtjs/protocol/server';
|
|
10
|
-
import { NeemataTypeError, registerDefaultLocale, type } from '@nmtjs/type';
|
|
11
|
-
import { prettifyError } from 'zod/mini';
|
|
12
|
-
import { config, defaultRuntimeConfig } from './config.js';
|
|
13
|
-
import { kDefaultProcedure } from './constants.js';
|
|
14
|
-
registerDefaultLocale();
|
|
15
|
-
export class ApiError extends ProtocolError {
|
|
16
|
-
toString() {
|
|
17
|
-
return `${this.code} ${this.message}: \n${inspect(this.data, true, 10, false)}`;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const NotFound = () => new ApiError(ErrorCode.NotFound, 'Procedure not found');
|
|
21
|
-
export class ApplicationApi {
|
|
22
|
-
options;
|
|
23
|
-
constructor(options) {
|
|
24
|
-
this.options = options;
|
|
25
|
-
}
|
|
26
|
-
find(procedureName) {
|
|
27
|
-
const procedure = this.options.procedures.get(procedureName);
|
|
28
|
-
if (procedure)
|
|
29
|
-
return procedure;
|
|
30
|
-
const fallback = this.options.procedures.get(kDefaultProcedure);
|
|
31
|
-
if (fallback)
|
|
32
|
-
return fallback;
|
|
33
|
-
throw NotFound();
|
|
34
|
-
}
|
|
35
|
-
async resolve(options) {
|
|
36
|
-
const { procedure, path } = this.find(options.procedure);
|
|
37
|
-
const metaBindings = this.resolveMetaBindings(path, procedure);
|
|
38
|
-
return Object.freeze({
|
|
39
|
-
stream: IsStreamProcedureContract(procedure.contract),
|
|
40
|
-
meta: createGatewayStaticMetaView(metaBindings.static),
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
async call(options) {
|
|
44
|
-
const callId = randomUUID();
|
|
45
|
-
const { payload, container, signal, connection } = options;
|
|
46
|
-
assert(container.scope === Scope.Call, 'Invalid container scope, expected to be Scope.Call');
|
|
47
|
-
const { procedure, path } = this.find(options.procedure);
|
|
48
|
-
const metaBindings = this.resolveMetaBindings(path, procedure);
|
|
49
|
-
const callOptions = Object.freeze({
|
|
50
|
-
callId,
|
|
51
|
-
payload,
|
|
52
|
-
container,
|
|
53
|
-
signal,
|
|
54
|
-
connection,
|
|
55
|
-
procedure,
|
|
56
|
-
path,
|
|
57
|
-
});
|
|
58
|
-
const timeout = procedure.contract.timeout ?? this.options.timeout;
|
|
59
|
-
const streamTimeoutSignal = procedure.streamTimeout
|
|
60
|
-
? AbortSignal.timeout(procedure.streamTimeout)
|
|
61
|
-
: undefined;
|
|
62
|
-
if (streamTimeoutSignal) {
|
|
63
|
-
container.provide(rpcStreamAbortSignal, streamTimeoutSignal);
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
const handle = await this.createProcedureHandler(callOptions, metaBindings);
|
|
67
|
-
return timeout
|
|
68
|
-
? await this.withTimeout(handle(payload), timeout)
|
|
69
|
-
: await handle(payload);
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
const handled = await this.handleFilters(callOptions, error);
|
|
73
|
-
if (handled === error && error instanceof ProtocolError === false) {
|
|
74
|
-
const logError = new Error('Unhandled error', { cause: error });
|
|
75
|
-
this.options.logger.error(logError);
|
|
76
|
-
throw new ApiError(ErrorCode.InternalServerError, 'Internal Server Error');
|
|
77
|
-
}
|
|
78
|
-
throw handled;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async createProcedureHandler(callOptions, metaBindings) {
|
|
82
|
-
const { callId, connection, procedure, container, path } = callOptions;
|
|
83
|
-
const callCtx = Object.freeze({
|
|
84
|
-
callId,
|
|
85
|
-
connection,
|
|
86
|
-
container,
|
|
87
|
-
path,
|
|
88
|
-
procedure,
|
|
89
|
-
});
|
|
90
|
-
const isIterableProcedure = IsStreamProcedureContract(procedure.contract);
|
|
91
|
-
this.applyStaticMetaBindings(container, metaBindings.static);
|
|
92
|
-
const middlewares = this.resolveMiddlewares(callOptions);
|
|
93
|
-
const handleProcedure = async (payload) => {
|
|
94
|
-
const middleware = (await middlewares).next().value;
|
|
95
|
-
if (middleware) {
|
|
96
|
-
const next = (...args) => handleProcedure(args.length === 0 ? payload : args[0]);
|
|
97
|
-
return middleware.handle(middleware.ctx, callCtx, next, payload);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
await this.applyFactoryMetaBindings(container, metaBindings.beforeDecode, callCtx, payload);
|
|
101
|
-
const input = this.handleInput(procedure, payload);
|
|
102
|
-
await this.applyFactoryMetaBindings(container, metaBindings.afterDecode, callCtx, input);
|
|
103
|
-
await this.handleGuards(callOptions, callCtx, input);
|
|
104
|
-
const { dependencies, handler } = procedure;
|
|
105
|
-
const context = await container.createContext(dependencies);
|
|
106
|
-
const result = await handler(context, input);
|
|
107
|
-
if (isIterableProcedure) {
|
|
108
|
-
return this.handleIterableOutput(procedure, result, metaBindings.config);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
return this.handleOutput(procedure, result, metaBindings.config);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
return handleProcedure;
|
|
116
|
-
}
|
|
117
|
-
resolveMetaBindings(path, procedure) {
|
|
118
|
-
const bindings = [
|
|
119
|
-
...this.options.meta,
|
|
120
|
-
...path.flatMap((router) => router.meta),
|
|
121
|
-
...procedure.meta,
|
|
122
|
-
];
|
|
123
|
-
const staticBindings = [];
|
|
124
|
-
const beforeDecode = [];
|
|
125
|
-
const afterDecode = [];
|
|
126
|
-
for (const binding of bindings) {
|
|
127
|
-
if (isStaticMetaBinding(binding)) {
|
|
128
|
-
staticBindings.push(binding);
|
|
129
|
-
}
|
|
130
|
-
else if (binding.phase === 'afterDecode') {
|
|
131
|
-
afterDecode.push(binding);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
beforeDecode.push(binding);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
const runtimeConfig = getStaticMetaValue(staticBindings, config);
|
|
138
|
-
return Object.freeze({
|
|
139
|
-
static: Object.freeze(staticBindings),
|
|
140
|
-
beforeDecode: Object.freeze(beforeDecode),
|
|
141
|
-
afterDecode: Object.freeze(afterDecode),
|
|
142
|
-
config: Object.freeze({ ...defaultRuntimeConfig, ...runtimeConfig }),
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
applyStaticMetaBindings(container, bindings) {
|
|
146
|
-
for (const binding of bindings) {
|
|
147
|
-
container.provide(getMetaBindingMeta(binding), binding.value);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
async applyFactoryMetaBindings(container, bindings, callCtx, input) {
|
|
151
|
-
for (const binding of bindings) {
|
|
152
|
-
const context = await container.createContext(binding.dependencies);
|
|
153
|
-
const value = await binding.resolve(context, callCtx, input);
|
|
154
|
-
container.provide(getMetaBindingMeta(binding), value);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
async resolveMiddlewares(callOptions) {
|
|
158
|
-
const { path, procedure, container } = callOptions;
|
|
159
|
-
const middlewares = [
|
|
160
|
-
...this.options.middlewares,
|
|
161
|
-
...path.flatMap((router) => [...router.middlewares]),
|
|
162
|
-
...procedure.middlewares,
|
|
163
|
-
];
|
|
164
|
-
const result = await Promise.all(middlewares.map(async (middleware) => {
|
|
165
|
-
const ctx = await container.createContext(middleware.dependencies);
|
|
166
|
-
return { handle: middleware.handle, ctx };
|
|
167
|
-
}));
|
|
168
|
-
return result[Symbol.iterator]();
|
|
169
|
-
}
|
|
170
|
-
withTimeout(response, timeout) {
|
|
171
|
-
const applyTimeout = response instanceof Promise && timeout > 0;
|
|
172
|
-
if (!applyTimeout)
|
|
173
|
-
return response;
|
|
174
|
-
return withTimeout(response, timeout, new ApiError(ErrorCode.RequestTimeout, 'Request Timeout'));
|
|
175
|
-
}
|
|
176
|
-
async handleGuards(callOptions, callCtx, payload) {
|
|
177
|
-
const { path, procedure, container } = callOptions;
|
|
178
|
-
const guards = [
|
|
179
|
-
...this.options.guards,
|
|
180
|
-
...path.flatMap((router) => [...router.guards]),
|
|
181
|
-
...procedure.guards,
|
|
182
|
-
];
|
|
183
|
-
for (const guard of guards) {
|
|
184
|
-
const ctx = await container.createContext(guard.dependencies);
|
|
185
|
-
const result = await guard.can(ctx, Object.freeze({ ...callCtx, payload }));
|
|
186
|
-
if (result === false)
|
|
187
|
-
throw new ApiError(ErrorCode.Forbidden);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
async handleFilters({ container }, error) {
|
|
191
|
-
if (this.options.filters.size) {
|
|
192
|
-
for (const filter of this.options.filters) {
|
|
193
|
-
if (error instanceof filter.errorClass) {
|
|
194
|
-
const ctx = await container.createContext(filter.dependencies);
|
|
195
|
-
const handledError = await filter.catch(ctx, error);
|
|
196
|
-
if (!handledError || handledError instanceof ApiError === false)
|
|
197
|
-
continue;
|
|
198
|
-
return handledError;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return error;
|
|
203
|
-
}
|
|
204
|
-
handleInput(procedure, payload) {
|
|
205
|
-
if (procedure.contract.input instanceof type.NeverType === false) {
|
|
206
|
-
const type = procedure.contract.input;
|
|
207
|
-
try {
|
|
208
|
-
return type.decode(payload);
|
|
209
|
-
}
|
|
210
|
-
catch (error) {
|
|
211
|
-
if (error instanceof NeemataTypeError)
|
|
212
|
-
throw new ApiError(ErrorCode.ValidationError, `Input validation error: \n${prettifyError(error)}`, error.issues);
|
|
213
|
-
throw error;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
handleIterableOutput(procedure, response, runtimeConfig) {
|
|
218
|
-
if (!isAsyncIterable(response))
|
|
219
|
-
throw new Error('Response is an async iterable');
|
|
220
|
-
const chunkType = procedure.contract.output;
|
|
221
|
-
if (chunkType instanceof type.NeverType)
|
|
222
|
-
throw new Error('Stream procedure must have a defined output type');
|
|
223
|
-
return async function* (onDone) {
|
|
224
|
-
try {
|
|
225
|
-
if (runtimeConfig.serializeOutput === false) {
|
|
226
|
-
yield* response;
|
|
227
|
-
}
|
|
228
|
-
else if (chunkType instanceof type.AnyType === false) {
|
|
229
|
-
for await (const chunk of response) {
|
|
230
|
-
yield chunkType.encode(chunk);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
yield* response;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
finally {
|
|
238
|
-
onDone?.();
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
handleOutput(procedure, response, runtimeConfig) {
|
|
243
|
-
if (procedure.contract.output instanceof type.NeverType === false) {
|
|
244
|
-
if (runtimeConfig.serializeOutput === false)
|
|
245
|
-
return response;
|
|
246
|
-
const type = procedure.contract.output;
|
|
247
|
-
return type.encode(response);
|
|
248
|
-
}
|
|
249
|
-
return undefined;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
//# sourceMappingURL=api.js.map
|
|
@@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aAAsC;QAEtC,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,YAAY,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC;YAClE,IAAI,aAAa,CAAC,eAAe,KAAK,KAAK;gBAAE,OAAO,QAAQ,CAAA;YAC5D,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAA;YACtC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC9B,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CACF"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { MetadataKind } from '@nmtjs/core';
|
|
2
|
-
export interface RuntimeConfig {
|
|
3
|
-
serializeOutput?: boolean;
|
|
4
|
-
}
|
|
5
|
-
export declare const config: import("@nmtjs/core").Meta<RuntimeConfig, MetadataKind.STATIC, Readonly<{
|
|
6
|
-
callId: string;
|
|
7
|
-
connection: import("@nmtjs/gateway").GatewayConnection;
|
|
8
|
-
container: import("@nmtjs/core").Container;
|
|
9
|
-
path: readonly import("./meta.ts").ApiMetaRouteContext[];
|
|
10
|
-
procedure: import("./meta.ts").ApiMetaProcedureContext;
|
|
11
|
-
}>>;
|
|
12
|
-
export declare const defaultRuntimeConfig: Readonly<{
|
|
13
|
-
serializeOutput: true;
|
|
14
|
-
}>;
|