@navios/commander 0.8.0 → 0.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navios/commander",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "author": {
5
5
  "name": "Oleksandr Hanzha",
6
6
  "email": "alex@granted.name"
@@ -35,6 +35,6 @@
35
35
  "zod": "^4.2.1"
36
36
  },
37
37
  "dependencies": {
38
- "@navios/di": "^0.8.0"
38
+ "@navios/di": "^0.9.0"
39
39
  }
40
40
  }
@@ -1,4 +1,4 @@
1
- import type { ClassType } from '@navios/core'
1
+ import type { ClassType, Registry } from '@navios/core'
2
2
 
3
3
  import { Injectable, InjectableScope, InjectionToken } from '@navios/core'
4
4
 
@@ -20,6 +20,16 @@ export interface CliModuleOptions {
20
20
  * Imported modules' commands will be available in this module.
21
21
  */
22
22
  imports?: ClassType[] | Set<ClassType>
23
+ /**
24
+ * Priority level for the module.
25
+ * Higher priority modules will be loaded first.
26
+ */
27
+ priority?: number
28
+ /**
29
+ * Registry to use for the module.
30
+ * Registry is used to store the module and its commands.
31
+ */
32
+ registry?: Registry
23
33
  }
24
34
 
25
35
  /**
@@ -45,7 +55,7 @@ export interface CliModuleOptions {
45
55
  * ```
46
56
  */
47
57
  export function CliModule(
48
- { commands = [], imports = [] }: CliModuleOptions = {
58
+ { commands = [], imports = [], priority, registry }: CliModuleOptions = {
49
59
  commands: [],
50
60
  imports: [],
51
61
  },
@@ -69,6 +79,8 @@ export function CliModule(
69
79
  return Injectable({
70
80
  token,
71
81
  scope: InjectableScope.Singleton,
82
+ priority,
83
+ registry,
72
84
  })(target, context)
73
85
  }
74
86
  }
@@ -1,4 +1,4 @@
1
- import type { ClassType } from '@navios/core'
1
+ import type { ClassType, Registry } from '@navios/core'
2
2
  import type { ZodObject } from 'zod'
3
3
 
4
4
  import { Injectable, InjectableScope, InjectionToken } from '@navios/core'
@@ -21,6 +21,16 @@ export interface CommandOptions {
21
21
  * If provided, options will be validated and parsed according to this schema.
22
22
  */
23
23
  optionsSchema?: ZodObject
24
+ /**
25
+ * Priority level for the command.
26
+ * Higher priority commands will be loaded first.
27
+ */
28
+ priority?: number
29
+ /**
30
+ * Registry to use for the command.
31
+ * Registry is used to store the command and its options schema.
32
+ */
33
+ registry?: Registry
24
34
  }
25
35
 
26
36
  /**
@@ -53,7 +63,12 @@ export interface CommandOptions {
53
63
  * }
54
64
  * ```
55
65
  */
56
- export function Command({ path, optionsSchema }: CommandOptions) {
66
+ export function Command({
67
+ path,
68
+ optionsSchema,
69
+ priority,
70
+ registry,
71
+ }: CommandOptions) {
57
72
  return function (target: ClassType, context: ClassDecoratorContext) {
58
73
  if (context.kind !== 'class') {
59
74
  throw new Error(
@@ -67,6 +82,8 @@ export function Command({ path, optionsSchema }: CommandOptions) {
67
82
  return Injectable({
68
83
  token,
69
84
  scope: InjectableScope.Singleton,
85
+ priority,
86
+ registry,
70
87
  })(target, context)
71
88
  }
72
89
  }
@@ -1,6 +1,6 @@
1
1
  import type { ClassTypeWithInstance, NaviosModule } from '@navios/core'
2
2
 
3
- import { Container, inject, Injectable } from '@navios/core'
3
+ import { Container, getInjectableToken, inject, Injectable } from '@navios/core'
4
4
 
5
5
  import type { CommandHandler } from '../interfaces/index.mjs'
6
6
  import type { CliModuleMetadata, CommandMetadata } from '../metadata/index.mjs'
@@ -65,7 +65,8 @@ export class CliModuleLoaderService {
65
65
  if (parentMetadata) {
66
66
  this.mergeMetadata(metadata, parentMetadata)
67
67
  }
68
- const moduleName = module.name
68
+ const moduleToken = getInjectableToken(module)
69
+ const moduleName = moduleToken.id
69
70
  if (this.modulesMetadata.has(moduleName)) {
70
71
  return
71
72
  }