nmtjs 0.16.0-beta.9 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/cli.js +2 -1
  2. package/dist/cli.js.map +1 -1
  3. package/dist/entrypoints/worker.js +9 -9
  4. package/dist/entrypoints/worker.js.map +1 -1
  5. package/dist/index.d.ts +58 -15
  6. package/dist/index.js +5 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/runtime/application/index.d.ts +1 -5
  9. package/dist/runtime/application/index.js +1 -5
  10. package/dist/runtime/application/index.js.map +1 -1
  11. package/dist/runtime/enums.d.ts +1 -12
  12. package/dist/runtime/enums.js +1 -14
  13. package/dist/runtime/enums.js.map +1 -1
  14. package/dist/runtime/hooks.d.ts +1 -4
  15. package/dist/runtime/hooks.js +1 -3
  16. package/dist/runtime/hooks.js.map +1 -1
  17. package/dist/runtime/index.d.ts +1 -3
  18. package/dist/runtime/index.js +1 -3
  19. package/dist/runtime/index.js.map +1 -1
  20. package/dist/runtime/injectables.d.ts +48 -7
  21. package/dist/runtime/injectables.js +19 -3
  22. package/dist/runtime/injectables.js.map +1 -1
  23. package/dist/runtime/jobs/job.d.ts +1 -2
  24. package/dist/runtime/jobs/job.js.map +1 -1
  25. package/dist/runtime/jobs/router.d.ts +2 -5
  26. package/dist/runtime/jobs/router.js +2 -3
  27. package/dist/runtime/jobs/router.js.map +1 -1
  28. package/dist/runtime/jobs/runner.d.ts +1 -1
  29. package/dist/runtime/jobs/runner.js +1 -1
  30. package/dist/runtime/jobs/runner.js.map +1 -1
  31. package/dist/runtime/jobs/types.d.ts +1 -1
  32. package/dist/runtime/metrics/metric.d.ts +2 -2
  33. package/dist/runtime/metrics/metric.js +1 -1
  34. package/dist/runtime/metrics/metric.js.map +1 -1
  35. package/dist/runtime/metrics/registry.d.ts +3 -3
  36. package/dist/runtime/metrics/registry.js +1 -1
  37. package/dist/runtime/metrics/registry.js.map +1 -1
  38. package/dist/runtime/metrics/server.js +1 -1
  39. package/dist/runtime/metrics/server.js.map +1 -1
  40. package/dist/runtime/plugin.d.ts +2 -8
  41. package/dist/runtime/plugin.js +1 -3
  42. package/dist/runtime/plugin.js.map +1 -1
  43. package/dist/runtime/runtime.d.ts +2 -2
  44. package/dist/runtime/runtime.js +1 -2
  45. package/dist/runtime/runtime.js.map +1 -1
  46. package/dist/runtime/server/applications.js +3 -0
  47. package/dist/runtime/server/applications.js.map +1 -1
  48. package/dist/runtime/server/config.d.ts +15 -12
  49. package/dist/runtime/server/config.js.map +1 -1
  50. package/dist/runtime/server/jobs.d.ts +6 -7
  51. package/dist/runtime/server/jobs.js +44 -30
  52. package/dist/runtime/server/jobs.js.map +1 -1
  53. package/dist/runtime/subscription/manager.d.ts +3 -3
  54. package/dist/runtime/subscription/manager.js +8 -8
  55. package/dist/runtime/subscription/manager.js.map +1 -1
  56. package/dist/runtime/subscription/redis.d.ts +1 -1
  57. package/dist/runtime/subscription/redis.js +16 -17
  58. package/dist/runtime/subscription/redis.js.map +1 -1
  59. package/dist/runtime/types.d.ts +3 -11
  60. package/dist/runtime/workers/application.d.ts +15 -33
  61. package/dist/runtime/workers/application.js +46 -139
  62. package/dist/runtime/workers/application.js.map +1 -1
  63. package/dist/runtime/workers/base.d.ts +0 -2
  64. package/dist/runtime/workers/base.js +3 -8
  65. package/dist/runtime/workers/base.js.map +1 -1
  66. package/dist/runtime/workers/job.js +2 -1
  67. package/dist/runtime/workers/job.js.map +1 -1
  68. package/dist/vite/server.js +1 -1
  69. package/dist/vite/server.js.map +1 -1
  70. package/package.json +19 -14
  71. package/src/cli.ts +2 -3
  72. package/src/entrypoints/worker.ts +11 -9
  73. package/src/index.ts +12 -5
  74. package/src/runtime/application/index.ts +1 -5
  75. package/src/runtime/enums.ts +2 -14
  76. package/src/runtime/hooks.ts +1 -5
  77. package/src/runtime/index.ts +2 -3
  78. package/src/runtime/injectables.ts +35 -6
  79. package/src/runtime/jobs/job.ts +1 -2
  80. package/src/runtime/jobs/router.ts +12 -15
  81. package/src/runtime/jobs/runner.ts +2 -2
  82. package/src/runtime/jobs/types.ts +1 -1
  83. package/src/runtime/metrics/metric.ts +2 -2
  84. package/src/runtime/metrics/registry.ts +5 -1
  85. package/src/runtime/metrics/server.ts +1 -1
  86. package/src/runtime/plugin.ts +2 -13
  87. package/src/runtime/runtime.ts +2 -4
  88. package/src/runtime/server/applications.ts +6 -0
  89. package/src/runtime/server/config.ts +27 -21
  90. package/src/runtime/server/jobs.ts +58 -34
  91. package/src/runtime/subscription/manager.ts +11 -14
  92. package/src/runtime/subscription/redis.ts +25 -23
  93. package/src/runtime/types.ts +3 -12
  94. package/src/runtime/workers/application.ts +76 -160
  95. package/src/runtime/workers/base.ts +9 -15
  96. package/src/runtime/workers/job.ts +3 -6
  97. package/src/vite/server.ts +1 -1
  98. package/dist/runtime/application/api/api.d.ts +0 -55
  99. package/dist/runtime/application/api/api.js +0 -252
  100. package/dist/runtime/application/api/api.js.map +0 -1
  101. package/dist/runtime/application/api/config.d.ts +0 -14
  102. package/dist/runtime/application/api/config.js +0 -6
  103. package/dist/runtime/application/api/config.js.map +0 -1
  104. package/dist/runtime/application/api/constants.d.ts +0 -14
  105. package/dist/runtime/application/api/constants.js +0 -8
  106. package/dist/runtime/application/api/constants.js.map +0 -1
  107. package/dist/runtime/application/api/filters.d.ts +0 -14
  108. package/dist/runtime/application/api/filters.js +0 -11
  109. package/dist/runtime/application/api/filters.js.map +0 -1
  110. package/dist/runtime/application/api/guards.d.ts +0 -15
  111. package/dist/runtime/application/api/guards.js +0 -8
  112. package/dist/runtime/application/api/guards.js.map +0 -1
  113. package/dist/runtime/application/api/index.d.ts +0 -23
  114. package/dist/runtime/application/api/index.js +0 -17
  115. package/dist/runtime/application/api/index.js.map +0 -1
  116. package/dist/runtime/application/api/logging.d.ts +0 -14
  117. package/dist/runtime/application/api/logging.js +0 -77
  118. package/dist/runtime/application/api/logging.js.map +0 -1
  119. package/dist/runtime/application/api/meta.d.ts +0 -21
  120. package/dist/runtime/application/api/meta.js +0 -2
  121. package/dist/runtime/application/api/meta.js.map +0 -1
  122. package/dist/runtime/application/api/middlewares.d.ts +0 -14
  123. package/dist/runtime/application/api/middlewares.js +0 -12
  124. package/dist/runtime/application/api/middlewares.js.map +0 -1
  125. package/dist/runtime/application/api/procedure.d.ts +0 -71
  126. package/dist/runtime/application/api/procedure.js +0 -41
  127. package/dist/runtime/application/api/procedure.js.map +0 -1
  128. package/dist/runtime/application/api/router.d.ts +0 -93
  129. package/dist/runtime/application/api/router.js +0 -55
  130. package/dist/runtime/application/api/router.js.map +0 -1
  131. package/dist/runtime/application/api/types.d.ts +0 -38
  132. package/dist/runtime/application/api/types.js +0 -2
  133. package/dist/runtime/application/api/types.js.map +0 -1
  134. package/dist/runtime/application/config.d.ts +0 -28
  135. package/dist/runtime/application/config.js +0 -25
  136. package/dist/runtime/application/config.js.map +0 -1
  137. package/dist/runtime/application/constants.d.ts +0 -2
  138. package/dist/runtime/application/constants.js +0 -2
  139. package/dist/runtime/application/constants.js.map +0 -1
  140. package/dist/runtime/application/hook.d.ts +0 -19
  141. package/dist/runtime/application/hook.js +0 -11
  142. package/dist/runtime/application/hook.js.map +0 -1
  143. package/dist/runtime/application/hooks.d.ts +0 -3
  144. package/dist/runtime/application/hooks.js +0 -4
  145. package/dist/runtime/application/hooks.js.map +0 -1
  146. package/src/runtime/application/api/api.ts +0 -406
  147. package/src/runtime/application/api/config.ts +0 -18
  148. package/src/runtime/application/api/constants.ts +0 -22
  149. package/src/runtime/application/api/filters.ts +0 -39
  150. package/src/runtime/application/api/guards.ts +0 -33
  151. package/src/runtime/application/api/index.ts +0 -69
  152. package/src/runtime/application/api/logging.ts +0 -110
  153. package/src/runtime/application/api/meta.ts +0 -37
  154. package/src/runtime/application/api/middlewares.ts +0 -37
  155. package/src/runtime/application/api/procedure.ts +0 -224
  156. package/src/runtime/application/api/router.ts +0 -247
  157. package/src/runtime/application/api/types.ts +0 -138
  158. package/src/runtime/application/config.ts +0 -82
  159. package/src/runtime/application/constants.ts +0 -4
  160. package/src/runtime/application/hook.ts +0 -51
  161. package/src/runtime/application/hooks.ts +0 -3
@@ -50,8 +50,9 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
50
50
  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 { LifecycleHook, WorkerType } from '../enums.js';
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,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAM3C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACvD,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;sBAPQ,MAAM;8BACN,cAAc;IAOzB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAA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AqB,EAAE,KAAK,EAAE,EAAE;yBAC/B,CAAC,CAAA;oBAChC,CAAC;yBAAM,CAAC;wBACN,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC;4BACnC,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;yBACjB,CAAC,CAAA;oBAChC,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAES,KAAK,CAAC,QAAQ;QACtB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAA;QACtD,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;IAES,CAAC,WAAW;QACpB,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;gBACjD,MAAM,GAAG,CAAA;gBACT,sEAAsE;gBACtE,iEAAiE;gBACjE,sBAAsB;YACxB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -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({
@@ -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;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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
- "bullmq": "5.74.1",
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
- "prom-client": "git@github.com:siimon/prom-client.git#d4d2dcb366384833951e0116caca707b5f62aa5e",
44
- "vite": "8.0.8",
45
- "@nmtjs/common": "0.16.0-beta.9",
46
- "@nmtjs/core": "0.16.0-beta.9",
47
- "@nmtjs/gateway": "0.16.0-beta.9",
48
- "@nmtjs/http-transport": "0.16.0-beta.9",
49
- "@nmtjs/contract": "0.16.0-beta.9",
50
- "@nmtjs/msgpack-format": "0.16.0-beta.9",
51
- "@nmtjs/json-format": "0.16.0-beta.9",
52
- "@nmtjs/ws-transport": "0.16.0-beta.9",
53
- "@nmtjs/protocol": "0.16.0-beta.9",
54
- "@nmtjs/type": "0.16.0-beta.9"
44
+ "vite": "8.0.14",
45
+ "@nmtjs/application": "0.16.1",
46
+ "@nmtjs/contract": "0.16.1",
47
+ "@nmtjs/common": "0.16.1",
48
+ "@nmtjs/core": "0.16.1",
49
+ "@nmtjs/gateway": "0.16.1",
50
+ "@nmtjs/protocol": "0.16.1",
51
+ "@nmtjs/http-transport": "0.16.1",
52
+ "@nmtjs/json-format": "0.16.1",
53
+ "@nmtjs/type": "0.16.1",
54
+ "@nmtjs/msgpack-format": "0.16.1",
55
+ "@nmtjs/ws-transport": "0.16.1"
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-beta.9",
78
+ "version": "0.16.1",
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, { specifier: appSpecifier, type }] of Object.entries(
79
- config.applications,
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
- isApplicationConfig,
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 config
42
- const appConfig = await import(
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 (!isApplicationConfig(appConfig)) {
48
- throw new Error(`Invalid application config for application: ${name}`)
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
- appConfig,
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 config changes with supersede logic.
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 (!isApplicationConfig(module.default)) {
151
- logger.error(new Error('Invalid application config during HMR reload'))
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'
@@ -1,5 +1 @@
1
- export * from './api/index.ts'
2
- export * from './config.ts'
3
- export * from './constants.ts'
4
- export * from './hook.ts'
5
- export * from './hooks.ts'
1
+ export * from '@nmtjs/application'
@@ -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'
@@ -1,5 +1 @@
1
- import { Hooks } from '@nmtjs/core'
2
-
3
- import type { LifecycleHookTypes } from './types.ts'
4
-
5
- export class LifecycleHooks extends Hooks<LifecycleHookTypes> {}
1
+ export { LifecycleHooks } from '@nmtjs/application'
@@ -1,14 +1,13 @@
1
- export * from './application/index.ts'
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,11 @@
1
- import { createLazyInjectable, Scope } from '@nmtjs/core'
1
+ import {
2
+ CoreInjectables,
3
+ createFactoryInjectable,
4
+ createLazyInjectable,
5
+ Scope,
6
+ } from '@nmtjs/core'
2
7
 
3
- import type { JobWorkerPool, WorkerType } from './enums.ts'
8
+ import type { WorkerType } from './enums.ts'
4
9
  import type { JobManagerInstance } from './jobs/manager.ts'
5
10
  import type { JobExecutionContext, SaveJobProgress } from './jobs/types.ts'
6
11
  import type { ServerStoreConfig } from './server/config.ts'
@@ -9,6 +14,7 @@ import type {
9
14
  SubscribeFn,
10
15
  SubscriptionAdapterType,
11
16
  } from './subscription/manager.ts'
17
+ import { SubscriptionManager } from './subscription/manager.ts'
12
18
 
13
19
  export const subscriptionAdapter =
14
20
  createLazyInjectable<SubscriptionAdapterType>(
@@ -16,10 +22,32 @@ export const subscriptionAdapter =
16
22
  'SubscriptionAdapter',
17
23
  )
18
24
 
19
- export const publish = createLazyInjectable<PublishFn>(Scope.Global, 'Publish')
25
+ export const subscriptionManager = createFactoryInjectable(
26
+ {
27
+ dependencies: {
28
+ adapter: subscriptionAdapter,
29
+ logger: CoreInjectables.logger,
30
+ },
31
+ factory: ({ adapter, logger }) =>
32
+ new SubscriptionManager({ logger, adapter }),
33
+ dispose: (manager) => manager.dispose(),
34
+ },
35
+ 'SubscriptionManager',
36
+ )
20
37
 
21
- export const subscribe = createLazyInjectable<SubscribeFn>(
22
- Scope.Global,
38
+ export const publish = createFactoryInjectable(
39
+ {
40
+ dependencies: { manager: subscriptionManager },
41
+ factory: ({ manager }): PublishFn => manager.publish.bind(manager),
42
+ },
43
+ 'Publish',
44
+ )
45
+
46
+ export const subscribe = createFactoryInjectable(
47
+ {
48
+ dependencies: { manager: subscriptionManager },
49
+ factory: ({ manager }): SubscribeFn => manager.subscribe.bind(manager),
50
+ },
23
51
  'Subscribe',
24
52
  )
25
53
 
@@ -38,7 +66,7 @@ export const workerType = createLazyInjectable<WorkerType>(
38
66
  'WorkerType',
39
67
  )
40
68
 
41
- export const jobWorkerPool = createLazyInjectable<JobWorkerPool>(
69
+ export const jobWorkerPool = createLazyInjectable<string>(
42
70
  Scope.Global,
43
71
  'JobWorkerPool',
44
72
  )
@@ -60,6 +88,7 @@ export const currentJobInfo = createLazyInjectable<JobExecutionContext>(
60
88
 
61
89
  export const RuntimeInjectables = {
62
90
  subscriptionAdapter,
91
+ subscriptionManager,
63
92
  publish,
64
93
  subscribe,
65
94
  jobManager,
@@ -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: JobWorkerPool
202
+ pool: string
204
203
  input: Input
205
204
  output: Output
206
205
  progress?: Progress
@@ -1,26 +1,23 @@
1
+ import type {
2
+ AnyGuard,
3
+ AnyMiddleware,
4
+ AnyProcedure,
5
+ AnyRouter,
6
+ AnyRouterMetaBinding,
7
+ ProcedureMetaBinding,
8
+ Router,
9
+ } from '@nmtjs/application'
1
10
  import type { MaybePromise } from '@nmtjs/common'
2
11
  import type { TProcedureContract, TRouterContract } from '@nmtjs/contract'
3
12
  import type { Dependencies, DependencyContext } from '@nmtjs/core'
4
13
  import type { NullableType, OptionalType } from '@nmtjs/type'
5
14
  import type { NeverType } from '@nmtjs/type/never'
15
+ import { createProcedure, createRouter } from '@nmtjs/application'
6
16
  import { CoreInjectables } from '@nmtjs/core'
7
17
  import { t } from '@nmtjs/type'
8
18
 
9
- import type { AnyGuard } from '../application/api/guards.ts'
10
- import type { AnyMiddleware } from '../application/api/middlewares.ts'
11
- import type {
12
- AnyProcedure,
13
- ProcedureMetaBinding,
14
- } from '../application/api/procedure.ts'
15
- import type {
16
- AnyRouter,
17
- AnyRouterMetaBinding,
18
- Router,
19
- } from '../application/api/router.ts'
20
19
  import type { AnyJob } from './job.ts'
21
20
  import type { JobStatus } from './types.ts'
22
- import { createProcedure } from '../application/api/procedure.ts'
23
- import { createRouter } from '../application/api/router.ts'
24
21
  import { jobManager } from '../injectables.ts'
25
22
 
26
23
  // ============================================================================
@@ -196,7 +193,7 @@ type JobItemSchemaType<T extends AnyJob> = t.ObjectType<{
196
193
  startedAt: OptionalType<t.NumberType>
197
194
  completedAt: OptionalType<t.NumberType>
198
195
  error: OptionalType<t.StringType>
199
- stacktrace: OptionalType<t.ArrayType<t.StringType>>
196
+ stacktrace: NullableType<t.ArrayType<t.StringType>>
200
197
  }>
201
198
 
202
199
  /** Type-level representation of createListOutputSchema output */
@@ -326,7 +323,7 @@ function createJobItemSchema<T extends AnyJob>(job: T): JobItemSchemaType<T> {
326
323
  startedAt: t.number().optional(),
327
324
  completedAt: t.number().optional(),
328
325
  error: t.string().optional(),
329
- stacktrace: t.array(t.string()).optional(),
326
+ stacktrace: t.array(t.string()).nullable(),
330
327
  })
331
328
  }
332
329
 
@@ -1,10 +1,11 @@
1
+ import type { LifecycleHooks } from '@nmtjs/application'
1
2
  import type { Container, Logger, LoggingOptions } from '@nmtjs/core'
2
3
  import type { Job } from 'bullmq'
4
+ import { LifecycleHook } from '@nmtjs/application'
3
5
  import { anyAbortSignal } from '@nmtjs/common'
4
6
  import { Scope } from '@nmtjs/core'
5
7
  import { UnrecoverableError } from 'bullmq'
6
8
 
7
- import type { LifecycleHooks } from '../hooks.ts'
8
9
  import type { AnyJob } from './job.ts'
9
10
  import type { AnyJobStep } from './step.ts'
10
11
  import type {
@@ -12,7 +13,6 @@ import type {
12
13
  JobProgressCheckpoint,
13
14
  StepResultEntry,
14
15
  } from './types.ts'
15
- import { LifecycleHook } from '../enums.ts'
16
16
  import {
17
17
  currentJobInfo,
18
18
  jobAbortSignal,
@@ -105,7 +105,7 @@ export interface JobItem<TInput = unknown, TOutput = unknown> {
105
105
  /** Error message if job failed */
106
106
  error?: string
107
107
  /** Stack trace if job failed */
108
- stacktrace?: string[]
108
+ stacktrace: string[] | null
109
109
  }
110
110
 
111
111
  // ============================================================================
@@ -1,6 +1,6 @@
1
1
  import type { ClassConstructorArgs } from '@nmtjs/common'
2
- import type { Metric, MetricConfiguration } from 'prom-client'
3
- import { Counter, Gauge, Histogram, Summary } from 'prom-client'
2
+ import type { Metric, MetricConfiguration } from '@nmtjs/prom-client'
3
+ import { Counter, Gauge, Histogram, Summary } from '@nmtjs/prom-client'
4
4
 
5
5
  import { registry } from './registry.ts'
6
6
 
@@ -1,4 +1,8 @@
1
- import { collectDefaultMetrics, register, WorkerRegistry } from 'prom-client'
1
+ import {
2
+ collectDefaultMetrics,
3
+ register,
4
+ WorkerRegistry,
5
+ } from '@nmtjs/prom-client'
2
6
 
3
7
  export const workerRegistry = new WorkerRegistry()
4
8
 
@@ -1,7 +1,7 @@
1
1
  import { createServer } from 'node:http'
2
2
 
3
3
  import type { Logger } from '@nmtjs/core'
4
- import { Pushgateway } from 'prom-client'
4
+ import { Pushgateway } from '@nmtjs/prom-client'
5
5
 
6
6
  import type { ServerConfig } from '../server/config.ts'
7
7
 
@@ -1,13 +1,2 @@
1
- import type { Provision } from '@nmtjs/core'
2
-
3
- import type { LifecycleHooks } from './hooks.ts'
4
-
5
- export interface RuntimePlugin {
6
- name: string
7
- hooks?: LifecycleHooks['_']['config']
8
- injections?: Provision[]
9
- }
10
-
11
- export function createPlugin<T extends RuntimePlugin>(plugin: T): T {
12
- return plugin
13
- }
1
+ export type { RuntimePlugin } from '@nmtjs/application'
2
+ export { createPlugin } from '@nmtjs/application'
@@ -1,9 +1,11 @@
1
+ import type { RuntimePlugin } from '@nmtjs/application'
1
2
  import type {
2
3
  AnyInjectable,
3
4
  Dependant,
4
5
  Logger,
5
6
  LoggingOptions,
6
7
  } from '@nmtjs/core'
8
+ import { LifecycleHook, LifecycleHooks } from '@nmtjs/application'
7
9
  import {
8
10
  Container,
9
11
  createLogger,
@@ -11,10 +13,6 @@ import {
11
13
  Scope,
12
14
  } from '@nmtjs/core'
13
15
 
14
- import type { RuntimePlugin } from './plugin.ts'
15
- import { LifecycleHook } from './enums.ts'
16
- import { LifecycleHooks } from './hooks.ts'
17
-
18
16
  export type BaseRuntimeOptions = {
19
17
  logger?: LoggingOptions
20
18
  container?: Container
@@ -120,6 +120,12 @@ export class ApplicationServerApplications extends EventEmitter<{
120
120
 
121
121
  // Add workers to the pool
122
122
  for (let i = 0; i < threadsConfig.length; i++) {
123
+ if (applicationPath.type !== 'neemata') {
124
+ throw new Error(
125
+ `Unsupported custom application worker: ${applicationName}`,
126
+ )
127
+ }
128
+
123
129
  const workerData = {
124
130
  runtime: {
125
131
  type: 'application',
@@ -1,10 +1,13 @@
1
+ import type {
2
+ ApplicationHost,
3
+ ApplicationHostDefinition,
4
+ TransportOptionsOf,
5
+ } from '@nmtjs/application'
1
6
  import type { LoggingOptions } from '@nmtjs/core'
2
- import type { Transport } from '@nmtjs/gateway'
3
7
  import type { ApplicationOptions } from '@nmtjs/proxy'
4
8
  import type { Applications } from 'nmtjs/runtime/types'
5
9
 
6
- import type { ApplicationConfig } from '../application/config.ts'
7
- import type { JobWorkerPool, StoreType } from '../enums.ts'
10
+ import type { StoreType } from '../enums.ts'
8
11
  import type { AnyJob } from '../jobs/job.ts'
9
12
  import type { JobsSchedulerOptions } from '../scheduler/index.ts'
10
13
  import type { SubscriptionAdapterType } from '../subscription/manager.ts'
@@ -26,25 +29,23 @@ export type ServerStoreConfig =
26
29
  | { type: StoreType.Redis; options: StoreTypeOptions[StoreType.Redis] }
27
30
  | { type: StoreType.Valkey; options: StoreTypeOptions[StoreType.Valkey] }
28
31
 
29
- export type ServerApplicationConfig<T = ApplicationConfig> =
30
- T extends ApplicationConfig<any, infer Transports>
32
+ export type ServerApplicationConfig<T = ApplicationHostDefinition> =
33
+ T extends ApplicationHostDefinition<any, infer Transports>
31
34
  ? {
32
35
  threads: {
33
- [K in keyof Transports]: Transports[K] extends Transport<
34
- any,
35
- infer Options
36
- >
37
- ? Options
38
- : never
36
+ [K in keyof Transports]: TransportOptionsOf<Transports[K]>
39
37
  }[]
40
38
  }
41
- : any
39
+ : T extends ApplicationHost<infer Transports>
40
+ ? {
41
+ threads: {
42
+ [K in keyof Transports]: TransportOptionsOf<Transports[K]>
43
+ }[]
44
+ }
45
+ : any
42
46
 
43
47
  export type ServerJobsConfig = {
44
- pools: {
45
- [JobWorkerPool.Io]: ServerPoolOptions
46
- [JobWorkerPool.Compute]: ServerPoolOptions
47
- }
48
+ pools: Record<string, ServerPoolOptions>
48
49
  jobs?: AnyJob[]
49
50
  /**
50
51
  * @deprecated Scheduler is currently being refactored and is not available.
@@ -53,14 +54,19 @@ export type ServerJobsConfig = {
53
54
  scheduler?: JobsSchedulerOptions
54
55
  }
55
56
 
57
+ type ServerApplicationDefinitionConfig<T> = T extends {
58
+ type: 'neemata'
59
+ definition: infer Definition
60
+ }
61
+ ? ServerApplicationConfig<Definition>
62
+ : ServerApplicationConfig<any>
63
+
56
64
  export interface ServerConfigInit {
57
65
  logger: LoggingOptions
58
66
  applications: {
59
- [K in keyof Applications]: Applications[K]['type'] extends 'neemata'
60
- ? ServerApplicationConfig<
61
- (Applications[K] & { type: 'neemata' })['definition']
62
- >
63
- : ServerApplicationConfig<any>
67
+ [K in keyof Applications]: ServerApplicationDefinitionConfig<
68
+ Applications[K]
69
+ >
64
70
  }
65
71
  store?: ServerStoreConfig
66
72
  /**