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,47 +1,29 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { GatewayOptions } from '@nmtjs/gateway';
|
|
3
|
-
import {
|
|
4
|
-
import type { ApplicationConfig } from '../application/config.ts';
|
|
5
|
-
import type { AnyFilter, AnyGuard, AnyMiddleware, AnyProcedure, AnyRouter, kDefaultProcedure as kDefaultProcedureKey } from '../application/index.ts';
|
|
6
|
-
import type { ServerConfig } from '../server/config.ts';
|
|
7
|
-
import { ApplicationApi } from '../application/api/api.ts';
|
|
8
|
-
import { ApplicationHooks } from '../application/hooks.ts';
|
|
9
|
-
import { kRootRouter } from '../application/index.ts';
|
|
1
|
+
import type { ApplicationHost, ApplicationHostDefinition, ApplicationHostOptions, ApplicationResolvedProcedure, NeemataApplication } from '@nmtjs/application';
|
|
2
|
+
import type { Gateway, GatewayOptions } from '@nmtjs/gateway';
|
|
3
|
+
import type { ServerApplicationConfig, ServerConfig } from '../server/config.ts';
|
|
10
4
|
import { BaseWorkerRuntime } from './base.ts';
|
|
11
5
|
export interface ApplicationWorkerRuntimeOptions {
|
|
12
6
|
name: string;
|
|
13
7
|
path: string;
|
|
14
|
-
transports:
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
};
|
|
8
|
+
transports: ServerApplicationConfig['threads'][number];
|
|
17
9
|
}
|
|
18
10
|
export declare class ApplicationWorkerRuntime extends BaseWorkerRuntime {
|
|
19
11
|
readonly config: ServerConfig;
|
|
20
12
|
readonly runtimeOptions: ApplicationWorkerRuntimeOptions;
|
|
21
|
-
protected
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
path: AnyRouter[];
|
|
30
|
-
}>;
|
|
31
|
-
filters: Set<AnyFilter>;
|
|
32
|
-
middlewares: Set<AnyMiddleware>;
|
|
33
|
-
guards: Set<AnyGuard>;
|
|
34
|
-
constructor(config: ServerConfig, runtimeOptions: ApplicationWorkerRuntimeOptions, appConfig: ApplicationConfig);
|
|
13
|
+
protected hostDefinition: ApplicationHostDefinition;
|
|
14
|
+
host: ApplicationHost;
|
|
15
|
+
constructor(config: ServerConfig, runtimeOptions: ApplicationWorkerRuntimeOptions, hostDefinition: ApplicationHostDefinition);
|
|
16
|
+
get application(): NeemataApplication;
|
|
17
|
+
get api(): import("@nmtjs/gateway").GatewayApi<ApplicationResolvedProcedure>;
|
|
18
|
+
get applicationHooks(): import("@nmtjs/application").ApplicationHooks;
|
|
19
|
+
get gateway(): Gateway<ApplicationResolvedProcedure>;
|
|
20
|
+
get transports(): GatewayOptions<ApplicationResolvedProcedure>['transports'];
|
|
35
21
|
start(): Promise<{
|
|
36
22
|
url: string;
|
|
37
23
|
type: import("@nmtjs/gateway").ProxyableTransportType;
|
|
38
24
|
}[]>;
|
|
39
25
|
stop(): Promise<void>;
|
|
40
|
-
reload(
|
|
41
|
-
|
|
42
|
-
protected
|
|
43
|
-
protected _dispose(): Promise<void>;
|
|
44
|
-
protected _dependents(): Generator<Dependant>;
|
|
45
|
-
protected registerApi(): void;
|
|
46
|
-
protected registerRouter(router: AnyRouter, path?: AnyRouter[]): void;
|
|
26
|
+
reload(hostDefinition: ApplicationHostDefinition): Promise<void>;
|
|
27
|
+
protected _dependents(): Generator<never, void, unknown>;
|
|
28
|
+
protected resolveHostOptions(): Pick<ApplicationHostOptions, 'transports' | 'gateway' | 'identity'>;
|
|
47
29
|
}
|
|
@@ -1,170 +1,77 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createApplicationHost, LifecycleHook } from '@nmtjs/application';
|
|
2
2
|
import { JsonFormat } from '@nmtjs/json-format/server';
|
|
3
3
|
import { MsgpackFormat } from '@nmtjs/msgpack-format/server';
|
|
4
4
|
import { ProtocolFormats } from '@nmtjs/protocol/server';
|
|
5
|
-
import {
|
|
6
|
-
import { ApplicationHooks } from '../application/hooks.js';
|
|
7
|
-
import { isProcedure, isRootRouter, isRouter, kDefaultProcedure, kRootRouter, } from '../application/index.js';
|
|
8
|
-
import { LifecycleHook, WorkerType } from '../enums.js';
|
|
5
|
+
import { WorkerType } from '../enums.js';
|
|
9
6
|
import { BaseWorkerRuntime } from './base.js';
|
|
10
7
|
export class ApplicationWorkerRuntime extends BaseWorkerRuntime {
|
|
11
8
|
config;
|
|
12
9
|
runtimeOptions;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
gateway;
|
|
17
|
-
transports;
|
|
18
|
-
routers = new Map();
|
|
19
|
-
procedures = new Map();
|
|
20
|
-
filters = new Set();
|
|
21
|
-
middlewares = new Set();
|
|
22
|
-
guards = new Set();
|
|
23
|
-
constructor(config, runtimeOptions, appConfig) {
|
|
10
|
+
hostDefinition;
|
|
11
|
+
host;
|
|
12
|
+
constructor(config, runtimeOptions, hostDefinition) {
|
|
24
13
|
super(config, {
|
|
25
14
|
logger: config.logger,
|
|
26
15
|
name: `Worker ${runtimeOptions.name}`,
|
|
27
|
-
plugins:
|
|
16
|
+
plugins: [],
|
|
28
17
|
}, WorkerType.Application);
|
|
29
18
|
this.config = config;
|
|
30
19
|
this.runtimeOptions = runtimeOptions;
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
20
|
+
this.hostDefinition = hostDefinition;
|
|
21
|
+
}
|
|
22
|
+
get application() {
|
|
23
|
+
return this.host.application;
|
|
24
|
+
}
|
|
25
|
+
get api() {
|
|
26
|
+
return this.application.api;
|
|
27
|
+
}
|
|
28
|
+
get applicationHooks() {
|
|
29
|
+
return this.application.applicationHooks;
|
|
30
|
+
}
|
|
31
|
+
get gateway() {
|
|
32
|
+
return this.host.gateway;
|
|
33
|
+
}
|
|
34
|
+
get transports() {
|
|
35
|
+
return this.host.transports;
|
|
43
36
|
}
|
|
44
37
|
async start() {
|
|
45
38
|
await this.initialize();
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
const options = this.runtimeOptions.transports[key];
|
|
49
|
-
const { factory, proxyable } = this.appConfig.transports[key];
|
|
50
|
-
this.transports[key] = { transport: await factory(options), proxyable };
|
|
51
|
-
}
|
|
52
|
-
this.gateway = new Gateway({
|
|
53
|
-
...this.appConfig.gateway,
|
|
39
|
+
this.host = createApplicationHost(this.hostDefinition.application, {
|
|
40
|
+
name: this.runtimeOptions.name,
|
|
54
41
|
logger: this.logger,
|
|
55
42
|
container: this.container,
|
|
56
|
-
hooks: this.lifecycleHooks,
|
|
57
43
|
formats: new ProtocolFormats([new JsonFormat(), new MsgpackFormat()]),
|
|
58
|
-
|
|
59
|
-
api: this.api,
|
|
60
|
-
identity: this.appConfig.identity,
|
|
61
|
-
});
|
|
62
|
-
return await this.gateway.start().finally(async () => {
|
|
63
|
-
await this.lifecycleHooks.callHook(LifecycleHook.Start);
|
|
44
|
+
...this.resolveHostOptions(),
|
|
64
45
|
});
|
|
46
|
+
return this.host.start();
|
|
65
47
|
}
|
|
66
48
|
async stop() {
|
|
67
|
-
await this.
|
|
49
|
+
await this.host.stop();
|
|
68
50
|
await this.dispose();
|
|
69
51
|
await this.lifecycleHooks.callHook(LifecycleHook.Stop);
|
|
70
52
|
}
|
|
71
|
-
async reload(
|
|
72
|
-
|
|
73
|
-
this.
|
|
74
|
-
this.plugins = appConfig.plugins;
|
|
75
|
-
await this.initialize();
|
|
76
|
-
this.gateway.options.identity =
|
|
77
|
-
this.appConfig.identity ?? this.gateway.options.identity;
|
|
78
|
-
await this.gateway.reload();
|
|
53
|
+
async reload(hostDefinition) {
|
|
54
|
+
this.hostDefinition = hostDefinition;
|
|
55
|
+
await this.host.reloadApplication(hostDefinition.application);
|
|
79
56
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
async _initialize() {
|
|
86
|
-
await super._initialize();
|
|
87
|
-
for (const hook of this.appConfig.hooks) {
|
|
88
|
-
this.applicationHooks.hook(hook.name, async (...args) => {
|
|
89
|
-
const ctx = await this.container.createContext(hook.dependencies);
|
|
90
|
-
await hook.handler(ctx, ...args);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
async _dispose() {
|
|
95
|
-
this.applicationHooks.removeAllHooks();
|
|
96
|
-
await super._dispose();
|
|
97
|
-
this.lifecycleHooks.removeHooks(this.appConfig.lifecycleHooks);
|
|
98
|
-
this.filters.clear();
|
|
99
|
-
this.middlewares.clear();
|
|
100
|
-
this.guards.clear();
|
|
101
|
-
this.routers.clear();
|
|
102
|
-
this.procedures.clear();
|
|
103
|
-
}
|
|
104
|
-
*_dependents() {
|
|
105
|
-
yield* this.appConfig.filters;
|
|
106
|
-
yield* this.appConfig.guards;
|
|
107
|
-
yield* this.appConfig.middlewares;
|
|
108
|
-
yield* this.appConfig.meta;
|
|
109
|
-
yield* this.appConfig.hooks;
|
|
110
|
-
for (const router of this.routers.values()) {
|
|
111
|
-
yield* router.meta;
|
|
112
|
-
}
|
|
113
|
-
for (const { procedure } of this.procedures.values()) {
|
|
114
|
-
yield procedure;
|
|
115
|
-
yield* procedure.meta;
|
|
116
|
-
yield* procedure.guards;
|
|
117
|
-
yield* procedure.middlewares;
|
|
57
|
+
*_dependents() { }
|
|
58
|
+
resolveHostOptions() {
|
|
59
|
+
const config = this.config.applications[this.runtimeOptions.name];
|
|
60
|
+
if (!config) {
|
|
61
|
+
throw new Error(`Missing server application config: ${this.runtimeOptions.name}`);
|
|
118
62
|
}
|
|
63
|
+
return {
|
|
64
|
+
transports: createHostTransportConfig(this.hostDefinition.transports, this.runtimeOptions.transports),
|
|
65
|
+
gateway: this.hostDefinition.gateway,
|
|
66
|
+
identity: this.hostDefinition.identity,
|
|
67
|
+
};
|
|
119
68
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
if (!isRootRouter(router)) {
|
|
126
|
-
throw new Error('Root router must be a root router');
|
|
127
|
-
}
|
|
128
|
-
this.routers.set(kRootRouter, router);
|
|
129
|
-
this.registerRouter(router, []);
|
|
130
|
-
if (router.default) {
|
|
131
|
-
if (!isProcedure(router.default)) {
|
|
132
|
-
throw new Error('Root router default must be a procedure');
|
|
133
|
-
}
|
|
134
|
-
this.procedures.set(kDefaultProcedure, {
|
|
135
|
-
procedure: router.default,
|
|
136
|
-
path: [router],
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
for (const filter of filters)
|
|
140
|
-
this.filters.add(filter);
|
|
141
|
-
for (const middleware of middlewares)
|
|
142
|
-
this.middlewares.add(middleware);
|
|
143
|
-
for (const guard of guards)
|
|
144
|
-
this.guards.add(guard);
|
|
145
|
-
}
|
|
146
|
-
registerRouter(router, path = []) {
|
|
147
|
-
for (const route of Object.values(router.routes)) {
|
|
148
|
-
if (isRouter(route)) {
|
|
149
|
-
const name = route.contract.name;
|
|
150
|
-
if (!name)
|
|
151
|
-
throw new Error('Nested routers must have a name');
|
|
152
|
-
if (this.routers.has(name)) {
|
|
153
|
-
throw new Error(`Router ${String(name)} already registered`);
|
|
154
|
-
}
|
|
155
|
-
this.routers.set(name, route);
|
|
156
|
-
this.registerRouter(route, [...path, router]);
|
|
157
|
-
}
|
|
158
|
-
else if (isProcedure(route)) {
|
|
159
|
-
const name = route.contract.name;
|
|
160
|
-
if (!name)
|
|
161
|
-
throw new Error('Procedures must have a name');
|
|
162
|
-
if (this.procedures.has(name)) {
|
|
163
|
-
throw new Error(`Procedure ${name} already registered`);
|
|
164
|
-
}
|
|
165
|
-
this.procedures.set(name, { procedure: route, path: [...path, router] });
|
|
166
|
-
}
|
|
167
|
-
}
|
|
69
|
+
}
|
|
70
|
+
function createHostTransportConfig(transports, options) {
|
|
71
|
+
const config = {};
|
|
72
|
+
for (const key in transports) {
|
|
73
|
+
config[key] = { transport: transports[key], options: options[key] };
|
|
168
74
|
}
|
|
75
|
+
return config;
|
|
169
76
|
}
|
|
170
77
|
//# sourceMappingURL=application.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../src/runtime/workers/application.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../src/runtime/workers/application.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAGxD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAQ7C,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAIlD,MAAM;IACN,cAAc;IACb,cAAc;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var e = new Error(message);
|
|
51
51
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
52
|
});
|
|
53
|
+
import { LifecycleHook } from '@nmtjs/application';
|
|
53
54
|
import { UnrecoverableError } from 'bullmq';
|
|
54
|
-
import {
|
|
55
|
+
import { WorkerType } from '../enums.js';
|
|
55
56
|
import { jobWorkerPool } from '../injectables.js';
|
|
56
57
|
import { ApplicationWorkerJobRunner } from '../jobs/runner.js';
|
|
57
58
|
import { BaseWorkerRuntime } from './base.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.js","sourceRoot":"","sources":["../../../src/runtime/workers/job.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"job.js","sourceRoot":"","sources":["../../../src/runtime/workers/job.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAK3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAO7C,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IAI1C,MAAM;IACN,cAAc;IAJzB,SAAS,CAA6B;IAEtC,YACW,MAAoB,EACpB,cAAuC;QAEhD,KAAK,CACH,MAAM,EACN,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,cAAc,cAAc,CAAC,QAAQ,EAAE,EAAE,EACxE,UAAU,CAAC,GAAG,CACf,CAAA;sB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ACtE,iEAAiE;gBACjE,sBAAsB;YACxB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/dist/vite/server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createServer as createViteServer } from 'vite';
|
|
|
3
3
|
// When externalized, Vite's ModuleRunner uses native Node import() which has
|
|
4
4
|
// a separate module cache from Vite's cache, causing the same module to be
|
|
5
5
|
// loaded twice with different object references.
|
|
6
|
-
const noExternalPackages = ['nmtjs', /^@nmtjs
|
|
6
|
+
const noExternalPackages = ['nmtjs', /^@nmtjs\/(?!prom-client$)/];
|
|
7
7
|
export function createServer(options, config, dev = {}) {
|
|
8
8
|
const usePolling = !!process.env.CI;
|
|
9
9
|
return createViteServer({
|
package/dist/vite/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAA;AAIvD,wEAAwE;AACxE,6EAA6E;AAC7E,2EAA2E;AAC3E,iDAAiD;AACjD,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/vite/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAA;AAIvD,wEAAwE;AACxE,6EAA6E;AAC7E,2EAA2E;AAC3E,iDAAiD;AACjD,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,2BAA2B,CAAC,CAAA;AAEjE,MAAM,UAAU,YAAY,CAC1B,OAA0B,EAC1B,MAAkB,EAClB,GAAG,GAA0B,EAAE;IAE/B,MAAM,UAAU,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAA;IAEnC,OAAO,gBAAgB,CAAC;QACtB,GAAG,MAAM;QACT,MAAM,EAAE;YACN,cAAc,EAAE,IAAI;YACpB,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS;SACrD;QACD,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE;QACnD,YAAY,EAAE;YACZ,OAAO,EAAE;gBACP,QAAQ,EAAE,QAAQ;gBAClB,GAAG;gBACH,OAAO,EAAE;oBACP,iEAAiE;oBACjE,UAAU,EAAE,kBAAkB;iBAC/B;gBACD,MAAM,EAAE;oBACN,eAAe,EAAE,IAAI,CAAC,SAAS,CAC7B,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAC/C;oBACD,uBAAuB,EAAE,IAAI,CAAC,SAAS,CACrC,IAAI,CAAC,SAAS,CACZ,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAC5C,CAAC,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;wBAC7B,OAAO;wBACP,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE;qBAC1B,CACF,CACF,CACF,CACF;iBACF;aACF;SACF;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -33,25 +33,26 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"
|
|
36
|
+
"@nmtjs/prom-client": "1.0.1",
|
|
37
|
+
"bullmq": "5.77.0",
|
|
37
38
|
"citty": "0.2.2",
|
|
38
39
|
"dedent": "^1.7.2",
|
|
39
40
|
"dotenv": "^17.4.2",
|
|
40
41
|
"ioredis": "^5.10.1",
|
|
41
42
|
"iovalkey": "^0.3.3",
|
|
42
43
|
"oxc-resolver": "11.19.1",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"@nmtjs/
|
|
46
|
-
"@nmtjs/
|
|
47
|
-
"@nmtjs/
|
|
48
|
-
"@nmtjs/
|
|
49
|
-
"@nmtjs/
|
|
50
|
-
"@nmtjs/
|
|
51
|
-
"@nmtjs/
|
|
52
|
-
"@nmtjs/
|
|
53
|
-
"@nmtjs/
|
|
54
|
-
"@nmtjs/
|
|
44
|
+
"vite": "8.0.14",
|
|
45
|
+
"@nmtjs/common": "0.16.0",
|
|
46
|
+
"@nmtjs/contract": "0.16.0",
|
|
47
|
+
"@nmtjs/application": "0.16.0",
|
|
48
|
+
"@nmtjs/core": "0.16.0",
|
|
49
|
+
"@nmtjs/gateway": "0.16.0",
|
|
50
|
+
"@nmtjs/json-format": "0.16.0",
|
|
51
|
+
"@nmtjs/http-transport": "0.16.0",
|
|
52
|
+
"@nmtjs/protocol": "0.16.0",
|
|
53
|
+
"@nmtjs/type": "0.16.0",
|
|
54
|
+
"@nmtjs/msgpack-format": "0.16.0",
|
|
55
|
+
"@nmtjs/ws-transport": "0.16.0"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@nmtjs/proxy": "1.0.0-beta.6",
|
|
@@ -74,7 +75,11 @@
|
|
|
74
75
|
"LICENSE.md",
|
|
75
76
|
"README.md"
|
|
76
77
|
],
|
|
77
|
-
"version": "0.16.0
|
|
78
|
+
"version": "0.16.0",
|
|
79
|
+
"repository": {
|
|
80
|
+
"type": "git",
|
|
81
|
+
"url": "https://github.com/neematajs/neemata"
|
|
82
|
+
},
|
|
78
83
|
"scripts": {
|
|
79
84
|
"clean-build": "rm -rf ./dist"
|
|
80
85
|
}
|
package/src/cli.ts
CHANGED
|
@@ -75,9 +75,8 @@ const mainCommand = defineCommand({
|
|
|
75
75
|
applicationImports = {}
|
|
76
76
|
const currentPkg = resolver.sync(process.cwd(), './package.json')
|
|
77
77
|
|
|
78
|
-
for (const [appName,
|
|
79
|
-
|
|
80
|
-
)) {
|
|
78
|
+
for (const [appName, application] of Object.entries(config.applications)) {
|
|
79
|
+
const { specifier: appSpecifier, type } = application
|
|
81
80
|
const resolution = resolver.sync(process.cwd(), appSpecifier)
|
|
82
81
|
if (resolution.error)
|
|
83
82
|
throw new Error(
|
|
@@ -4,7 +4,7 @@ import type { ServerConfig } from '../runtime/index.ts'
|
|
|
4
4
|
import type { RunWorkerOptions } from './thread.ts'
|
|
5
5
|
import {
|
|
6
6
|
ApplicationWorkerRuntime,
|
|
7
|
-
|
|
7
|
+
isApplicationHostDefinition,
|
|
8
8
|
JobWorkerRuntime,
|
|
9
9
|
} from '../runtime/index.ts'
|
|
10
10
|
|
|
@@ -38,21 +38,21 @@ async function initializeApplicationWorker(
|
|
|
38
38
|
) {
|
|
39
39
|
const { name, path, transportsData } = options
|
|
40
40
|
|
|
41
|
-
// Load initial application
|
|
42
|
-
const
|
|
41
|
+
// Load initial application host definition
|
|
42
|
+
const hostDefinition = await import(
|
|
43
43
|
/* @vite-ignore */
|
|
44
44
|
path
|
|
45
45
|
).then((m) => m.default)
|
|
46
46
|
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`Invalid application
|
|
47
|
+
if (!isApplicationHostDefinition(hostDefinition)) {
|
|
48
|
+
throw new Error(`Invalid application host definition: ${name}`)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// Create runtime
|
|
52
52
|
const runtime = new ApplicationWorkerRuntime(
|
|
53
53
|
serverConfig,
|
|
54
54
|
{ name, path, transports: transportsData },
|
|
55
|
-
|
|
55
|
+
hostDefinition,
|
|
56
56
|
)
|
|
57
57
|
|
|
58
58
|
// Set up HMR with supersede logic
|
|
@@ -62,7 +62,7 @@ async function initializeApplicationWorker(
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Set up HMR acceptance for application
|
|
65
|
+
* Set up HMR acceptance for application host definition changes with supersede logic.
|
|
66
66
|
*
|
|
67
67
|
* When a reload is in progress and another HMR event arrives, the pending
|
|
68
68
|
* reload is superseded - only the most recent config is applied.
|
|
@@ -147,8 +147,10 @@ function setupApplicationHMR(runtime: ApplicationWorkerRuntime) {
|
|
|
147
147
|
logger.debug('Received HMR update')
|
|
148
148
|
if (!module) return
|
|
149
149
|
|
|
150
|
-
if (!
|
|
151
|
-
logger.error(
|
|
150
|
+
if (!isApplicationHostDefinition(module.default)) {
|
|
151
|
+
logger.error(
|
|
152
|
+
new Error('Invalid application host definition during HMR reload'),
|
|
153
|
+
)
|
|
152
154
|
return
|
|
153
155
|
}
|
|
154
156
|
|
package/src/index.ts
CHANGED
|
@@ -15,19 +15,22 @@ import {
|
|
|
15
15
|
createContractProcedure,
|
|
16
16
|
createContractRouter,
|
|
17
17
|
createFilter,
|
|
18
|
+
defineApplicationHost,
|
|
18
19
|
createGuard,
|
|
19
20
|
createHook,
|
|
20
|
-
createJob,
|
|
21
|
-
createJobRouterOperation,
|
|
22
|
-
createJobsRouter,
|
|
23
21
|
createMeta,
|
|
24
22
|
createMiddleware,
|
|
25
23
|
createPlugin,
|
|
26
24
|
createProcedure,
|
|
27
25
|
createRootRouter,
|
|
28
26
|
createRouter,
|
|
29
|
-
createStep,
|
|
30
27
|
defineApplication,
|
|
28
|
+
} from '@nmtjs/application'
|
|
29
|
+
import {
|
|
30
|
+
createJob,
|
|
31
|
+
createJobRouterOperation,
|
|
32
|
+
createJobsRouter,
|
|
33
|
+
createStep,
|
|
31
34
|
defineServer,
|
|
32
35
|
RuntimeInjectables,
|
|
33
36
|
} from './runtime/index.ts'
|
|
@@ -40,6 +43,7 @@ import {
|
|
|
40
43
|
|
|
41
44
|
export namespace neemata {
|
|
42
45
|
export const app = defineApplication
|
|
46
|
+
export const host = defineApplicationHost
|
|
43
47
|
export const server = defineServer
|
|
44
48
|
export const injectables = Object.freeze({
|
|
45
49
|
...CoreInjectables,
|
|
@@ -90,9 +94,12 @@ export { t } from '@nmtjs/type'
|
|
|
90
94
|
|
|
91
95
|
export {
|
|
92
96
|
ApiError,
|
|
97
|
+
defineApplicationHost,
|
|
93
98
|
defineApplication,
|
|
94
|
-
JobWorkerPool,
|
|
95
99
|
LifecycleHook,
|
|
100
|
+
} from '@nmtjs/application'
|
|
101
|
+
|
|
102
|
+
export {
|
|
96
103
|
StoreType,
|
|
97
104
|
WorkerType,
|
|
98
105
|
} from './runtime/index.ts'
|
package/src/runtime/enums.ts
CHANGED
|
@@ -3,22 +3,10 @@ export enum StoreType {
|
|
|
3
3
|
Valkey = 'Valkey',
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
export enum JobWorkerPool {
|
|
7
|
-
Io = 'Io',
|
|
8
|
-
Compute = 'Compute',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export enum LifecycleHook {
|
|
12
|
-
BeforeInitialize = 'lifecycle:beforeInitialize',
|
|
13
|
-
AfterInitialize = 'lifecycle:afterInitialize',
|
|
14
|
-
BeforeDispose = 'lifecycle:beforeDispose',
|
|
15
|
-
AfterDispose = 'lifecycle:afterDispose',
|
|
16
|
-
Stop = 'lifecycle:stop',
|
|
17
|
-
Start = 'lifecycle:start',
|
|
18
|
-
}
|
|
19
|
-
|
|
20
6
|
export enum WorkerType {
|
|
21
7
|
Application = 'Application',
|
|
22
8
|
Job = 'Job',
|
|
23
9
|
Command = 'Command',
|
|
24
10
|
}
|
|
11
|
+
|
|
12
|
+
export { LifecycleHook } from '@nmtjs/application'
|
package/src/runtime/hooks.ts
CHANGED
package/src/runtime/index.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from '@nmtjs/application'
|
|
2
|
+
|
|
2
3
|
export * from './constants.ts'
|
|
3
4
|
export * from './enums.ts'
|
|
4
|
-
export * from './hooks.ts'
|
|
5
5
|
export * from './injectables.ts'
|
|
6
6
|
export * from './jobs/job.ts'
|
|
7
7
|
export * from './jobs/manager.ts'
|
|
8
8
|
export * from './jobs/router.ts'
|
|
9
9
|
export * from './jobs/step.ts'
|
|
10
10
|
export * from './jobs/types.ts'
|
|
11
|
-
export * from './plugin.ts'
|
|
12
11
|
export * from './runtime.ts'
|
|
13
12
|
export * from './scheduler/index.ts'
|
|
14
13
|
export * from './server/config.ts'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLazyInjectable, Scope } from '@nmtjs/core'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { WorkerType } from './enums.ts'
|
|
4
4
|
import type { JobManagerInstance } from './jobs/manager.ts'
|
|
5
5
|
import type { JobExecutionContext, SaveJobProgress } from './jobs/types.ts'
|
|
6
6
|
import type { ServerStoreConfig } from './server/config.ts'
|
|
@@ -38,7 +38,7 @@ export const workerType = createLazyInjectable<WorkerType>(
|
|
|
38
38
|
'WorkerType',
|
|
39
39
|
)
|
|
40
40
|
|
|
41
|
-
export const jobWorkerPool = createLazyInjectable<
|
|
41
|
+
export const jobWorkerPool = createLazyInjectable<string>(
|
|
42
42
|
Scope.Global,
|
|
43
43
|
'JobWorkerPool',
|
|
44
44
|
)
|
package/src/runtime/jobs/job.ts
CHANGED
|
@@ -4,7 +4,6 @@ import type { t } from '@nmtjs/type'
|
|
|
4
4
|
import type { AnyObjectLikeType, ObjectType } from '@nmtjs/type/object'
|
|
5
5
|
import { tryCaptureStackTrace } from '@nmtjs/common'
|
|
6
6
|
|
|
7
|
-
import type { JobWorkerPool } from '../enums.ts'
|
|
8
7
|
import type { AnyJobStep, JobStep } from './step.ts'
|
|
9
8
|
import { kJobKey } from '../constants.ts'
|
|
10
9
|
import { isJobStep } from './step.ts'
|
|
@@ -200,7 +199,7 @@ export interface JobOptions<
|
|
|
200
199
|
Data = any,
|
|
201
200
|
> {
|
|
202
201
|
name: Name
|
|
203
|
-
pool:
|
|
202
|
+
pool: string
|
|
204
203
|
input: Input
|
|
205
204
|
output: Output
|
|
206
205
|
progress?: Progress
|