@navios/commander 1.5.0 → 1.6.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/.turbo/turbo-build.log +48 -0
- package/.turbo/turbo-check.log +0 -0
- package/.turbo/turbo-lint.log +2 -0
- package/.turbo/turbo-test$colon$ci.log +109 -0
- package/.turbo/turbo-test.log +107 -0
- package/CHANGELOG.md +15 -3
- package/README.md +8 -16
- package/dist/src/commander.factory.d.mts +126 -122
- package/dist/src/commander.factory.d.mts.map +1 -1
- package/dist/src/commands/help.command.d.mts +15 -11
- package/dist/src/commands/help.command.d.mts.map +1 -1
- package/dist/src/commands/index.d.mts +2 -2
- package/dist/src/decorators/cli-module.decorator.d.mts +51 -40
- package/dist/src/decorators/cli-module.decorator.d.mts.map +1 -1
- package/dist/src/decorators/command.decorator.d.mts +49 -37
- package/dist/src/decorators/command.decorator.d.mts.map +1 -1
- package/dist/src/decorators/index.d.mts +3 -3
- package/dist/src/define-environment.d.mts +9 -8
- package/dist/src/define-environment.d.mts.map +1 -1
- package/dist/src/index.d.mts +10 -10
- package/dist/src/interfaces/abstract-cli-adapter.interface.d.mts +45 -45
- package/dist/src/interfaces/command-handler.interface.d.mts +14 -10
- package/dist/src/interfaces/command-handler.interface.d.mts.map +1 -1
- package/dist/src/interfaces/commander-execution-context.interface.d.mts +40 -30
- package/dist/src/interfaces/commander-execution-context.interface.d.mts.map +1 -1
- package/dist/src/interfaces/environment.interface.d.mts +7 -7
- package/dist/src/interfaces/index.d.mts +5 -5
- package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts +6 -5
- package/dist/src/legacy-compat/decorators/cli-module.decorator.d.mts.map +1 -1
- package/dist/src/legacy-compat/decorators/command.decorator.d.mts +7 -6
- package/dist/src/legacy-compat/decorators/command.decorator.d.mts.map +1 -1
- package/dist/src/legacy-compat/decorators/index.d.mts +3 -3
- package/dist/src/legacy-compat/index.d.mts +3 -3
- package/dist/src/metadata/command-entry.metadata.d.mts +5 -5
- package/dist/src/metadata/command-entry.metadata.d.mts.map +1 -1
- package/dist/src/metadata/command.metadata.d.mts +30 -24
- package/dist/src/metadata/command.metadata.d.mts.map +1 -1
- package/dist/src/metadata/index.d.mts +3 -3
- package/dist/src/overrides/help.command.d.mts +15 -11
- package/dist/src/overrides/help.command.d.mts.map +1 -1
- package/dist/src/services/cli-parser.service.d.mts +54 -54
- package/dist/src/services/cli-parser.service.d.mts.map +1 -1
- package/dist/src/services/command-registry.service.d.mts +75 -74
- package/dist/src/services/command-registry.service.d.mts.map +1 -1
- package/dist/src/services/commander-adapter.service.d.mts +53 -48
- package/dist/src/services/commander-adapter.service.d.mts.map +1 -1
- package/dist/src/services/index.d.mts +4 -4
- package/dist/src/tokens/execution-context.token.d.mts +9 -4
- package/dist/src/tokens/execution-context.token.d.mts.map +1 -1
- package/dist/src/tokens/help-command.token.d.mts +5 -4
- package/dist/src/tokens/index.d.mts +2 -2
- package/dist/src/utils/index.d.mts +2 -2
- package/dist/src/utils/runtime.d.mts +2 -2
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/tsdown.config.d.mts +3 -3
- package/dist/vitest.config.d.mts +3 -3
- package/lib/{cli-module.decorator-CRaNGvgl.d.cts → cli-module.decorator-BV3vVKlR.d.cts} +60 -55
- package/lib/cli-module.decorator-BV3vVKlR.d.cts.map +1 -0
- package/lib/{cli-module.decorator-CkP22084.cjs → cli-module.decorator-CXt38aqF.cjs} +2 -2
- package/lib/cli-module.decorator-CXt38aqF.cjs.map +1 -0
- package/lib/{cli-module.decorator-UGbtkRYc.mjs → cli-module.decorator-DAjf_r_W.mjs} +2 -2
- package/lib/cli-module.decorator-DAjf_r_W.mjs.map +1 -0
- package/lib/{cli-module.decorator-bsP5gEn7.d.mts → cli-module.decorator-DDlgpTgI.d.mts} +133 -118
- package/lib/cli-module.decorator-DDlgpTgI.d.mts.map +1 -0
- package/lib/{command.decorator-UrNJmQN0.cjs → command.decorator-HziankUv.cjs} +3 -3
- package/lib/command.decorator-HziankUv.cjs.map +1 -0
- package/lib/{command.decorator-DVLSAqYZ.mjs → command.decorator-QiRU7ny3.mjs} +3 -3
- package/lib/command.decorator-QiRU7ny3.mjs.map +1 -0
- package/lib/{help-command.token-CMWYI6em.cjs → help-command.token-DamE31Aw.cjs} +4 -4
- package/lib/{help-command.token-CMWYI6em.cjs.map → help-command.token-DamE31Aw.cjs.map} +1 -1
- package/lib/{help-command.token-C0Kgj60o.mjs → help-command.token-XHx3WkoD.mjs} +4 -4
- package/lib/{help-command.token-C0Kgj60o.mjs.map → help-command.token-XHx3WkoD.mjs.map} +1 -1
- package/lib/{help.command-dtZbhq0w.mjs → help.command-Bynoll_7.mjs} +5 -8
- package/lib/help.command-Bynoll_7.mjs.map +1 -0
- package/lib/{help.command-DQyv6ali.cjs → help.command-DvKmMpB7.cjs} +6 -9
- package/lib/help.command-DvKmMpB7.cjs.map +1 -0
- package/lib/index.cjs +118 -106
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +294 -284
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.mts +221 -221
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +117 -105
- package/lib/index.mjs.map +1 -1
- package/lib/legacy-compat/index.cjs +6 -28
- package/lib/legacy-compat/index.cjs.map +1 -1
- package/lib/legacy-compat/index.d.cts +3 -2
- package/lib/legacy-compat/index.d.cts.map +1 -1
- package/lib/legacy-compat/index.d.mts +3 -2
- package/lib/legacy-compat/index.d.mts.map +1 -1
- package/lib/legacy-compat/index.mjs +4 -25
- package/lib/legacy-compat/index.mjs.map +1 -1
- package/package.json +26 -16
- package/src/__tests__/commander.factory.e2e.spec.mts +127 -79
- package/src/commands/help.command.mts +1 -1
- package/src/decorators/cli-module.decorator.mts +4 -9
- package/src/decorators/command.decorator.mts +4 -4
- package/src/define-environment.mts +4 -4
- package/src/interfaces/command-handler.interface.mts +8 -4
- package/src/interfaces/commander-execution-context.interface.mts +14 -1
- package/src/legacy-compat/decorators/cli-module.decorator.mts +2 -1
- package/src/legacy-compat/decorators/command.decorator.mts +3 -2
- package/src/metadata/command-entry.metadata.mts +3 -6
- package/src/metadata/command.metadata.mts +6 -8
- package/src/overrides/help.command.mts +2 -2
- package/src/services/__tests__/cli-parser.service.spec.mts +23 -178
- package/src/services/cli-parser.service.mts +23 -27
- package/src/services/command-registry.service.mts +5 -5
- package/src/services/commander-adapter.service.mts +12 -20
- package/src/tokens/execution-context.token.mts +4 -6
- package/tsconfig.json +3 -0
- package/lib/cli-module.decorator-CRaNGvgl.d.cts.map +0 -1
- package/lib/cli-module.decorator-CkP22084.cjs.map +0 -1
- package/lib/cli-module.decorator-UGbtkRYc.mjs.map +0 -1
- package/lib/cli-module.decorator-bsP5gEn7.d.mts.map +0 -1
- package/lib/command.decorator-DVLSAqYZ.mjs.map +0 -1
- package/lib/command.decorator-UrNJmQN0.cjs.map +0 -1
- package/lib/help.command-DQyv6ali.cjs.map +0 -1
- package/lib/help.command-dtZbhq0w.mjs.map +0 -1
- package/project.json +0 -66
package/dist/tsdown.config.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const _default: import(
|
|
2
|
-
export default _default
|
|
3
|
-
//# sourceMappingURL=tsdown.config.d.mts.map
|
|
1
|
+
declare const _default: import('tsdown').UserConfig
|
|
2
|
+
export default _default
|
|
3
|
+
//# sourceMappingURL=tsdown.config.d.mts.map
|
package/dist/vitest.config.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const _default: import(
|
|
2
|
-
export default _default
|
|
3
|
-
//# sourceMappingURL=vitest.config.d.mts.map
|
|
1
|
+
declare const _default: import('vitest/config').UserWorkspaceConfig
|
|
2
|
+
export default _default
|
|
3
|
+
//# sourceMappingURL=vitest.config.d.mts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ClassType, ClassTypeWithInstance, InjectionToken, Registry } from "@navios/core";
|
|
2
|
-
import {
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
3
|
|
|
4
4
|
//#region src/interfaces/command-handler.interface.d.mts
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Interface that all command classes must implement.
|
|
7
8
|
*
|
|
@@ -13,7 +14,7 @@ import { ZodObject } from "zod";
|
|
|
13
14
|
* @example
|
|
14
15
|
* ```typescript
|
|
15
16
|
* import { Command, CommandHandler } from '@navios/commander'
|
|
16
|
-
* import { z } from 'zod'
|
|
17
|
+
* import { z } from 'zod/v4'
|
|
17
18
|
*
|
|
18
19
|
* const optionsSchema = z.object({
|
|
19
20
|
* name: z.string()
|
|
@@ -23,20 +24,24 @@ import { ZodObject } from "zod";
|
|
|
23
24
|
*
|
|
24
25
|
* @Command({ path: 'greet', optionsSchema })
|
|
25
26
|
* export class GreetCommand implements CommandHandler<Options> {
|
|
26
|
-
* async execute(options: Options) {
|
|
27
|
+
* async execute(options: Options, positionals?: string[]) {
|
|
27
28
|
* console.log(`Hello, ${options.name}!`)
|
|
29
|
+
* if (positionals?.length) {
|
|
30
|
+
* console.log(`Files: ${positionals.join(', ')}`)
|
|
31
|
+
* }
|
|
28
32
|
* }
|
|
29
33
|
* }
|
|
30
34
|
* ```
|
|
31
35
|
*/
|
|
32
36
|
interface CommandHandler<TOptions = any> {
|
|
33
37
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
* Executes the command with the provided options and positional arguments.
|
|
39
|
+
*
|
|
40
|
+
* @param options - The validated command options (validated against the command's schema if provided)
|
|
41
|
+
* @param positionals - Positional arguments that don't match any option flags
|
|
42
|
+
* @returns A promise or void
|
|
43
|
+
*/
|
|
44
|
+
execute(options: TOptions, positionals?: string[]): void | Promise<void>;
|
|
40
45
|
}
|
|
41
46
|
//#endregion
|
|
42
47
|
//#region src/decorators/command.decorator.d.mts
|
|
@@ -47,34 +52,34 @@ interface CommandHandler<TOptions = any> {
|
|
|
47
52
|
*/
|
|
48
53
|
interface CommandOptions {
|
|
49
54
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
* The token to use for the command.
|
|
56
|
+
* If provided, the command will be registered with this token.
|
|
57
|
+
*/
|
|
53
58
|
token?: InjectionToken<ClassTypeWithInstance<CommandHandler<any>>>;
|
|
54
59
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
* The command path that users will invoke from the CLI.
|
|
61
|
+
* Can be a single word (e.g., 'greet') or multi-word with colons (e.g., 'user:create', 'db:migrate').
|
|
62
|
+
*/
|
|
58
63
|
path: string;
|
|
59
64
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
* Optional description of the command for help text.
|
|
66
|
+
* Displayed when users run `help` or `--help`.
|
|
67
|
+
*/
|
|
63
68
|
description?: string;
|
|
64
69
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
optionsSchema?: ZodObject;
|
|
70
|
+
* Optional zod/v4 schema for validating command options.
|
|
71
|
+
* If provided, options will be validated and parsed according to this schema.
|
|
72
|
+
*/
|
|
73
|
+
optionsSchema?: z.ZodObject;
|
|
69
74
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
* Priority level for the command.
|
|
76
|
+
* Higher priority commands will be loaded first.
|
|
77
|
+
*/
|
|
73
78
|
priority?: number;
|
|
74
79
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
* Registry to use for the command.
|
|
81
|
+
* Registry is used to store the command and its options schema.
|
|
82
|
+
*/
|
|
78
83
|
registry?: Registry;
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
@@ -89,7 +94,7 @@ interface CommandOptions {
|
|
|
89
94
|
* @example
|
|
90
95
|
* ```typescript
|
|
91
96
|
* import { Command, CommandHandler } from '@navios/commander'
|
|
92
|
-
* import { z } from 'zod'
|
|
97
|
+
* import { z } from 'zod/v4'
|
|
93
98
|
*
|
|
94
99
|
* const optionsSchema = z.object({
|
|
95
100
|
* name: z.string(),
|
|
@@ -114,7 +119,7 @@ declare function Command({
|
|
|
114
119
|
optionsSchema,
|
|
115
120
|
priority,
|
|
116
121
|
registry
|
|
117
|
-
}: CommandOptions): (target: ClassType, context: ClassDecoratorContext) => any;
|
|
122
|
+
}: CommandOptions): (target: ClassType, context: ClassDecoratorContext<abstract new (...args: any) => any>) => any;
|
|
118
123
|
//#endregion
|
|
119
124
|
//#region src/decorators/cli-module.decorator.d.mts
|
|
120
125
|
/**
|
|
@@ -124,41 +129,41 @@ declare function Command({
|
|
|
124
129
|
*/
|
|
125
130
|
interface CliModuleOptions {
|
|
126
131
|
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
132
|
+
* Array or Set of command classes to register in this module.
|
|
133
|
+
* Commands must be decorated with `@Command`.
|
|
134
|
+
*/
|
|
130
135
|
commands?: ClassType[] | Set<ClassType>;
|
|
131
136
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
* Array or Set of controller classes for HTTP endpoints.
|
|
138
|
+
* Allows mixing HTTP and CLI functionality in the same module.
|
|
139
|
+
*/
|
|
135
140
|
controllers?: ClassType[] | Set<ClassType>;
|
|
136
141
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
* Array or Set of other modules to import.
|
|
143
|
+
* Imported modules' commands and controllers will be available.
|
|
144
|
+
*/
|
|
140
145
|
imports?: ClassType[] | Set<ClassType>;
|
|
141
146
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
147
|
+
* Guards to apply to all controllers in this module.
|
|
148
|
+
* Guards are executed in reverse order (last guard first).
|
|
149
|
+
*/
|
|
145
150
|
guards?: ClassType[] | Set<ClassType>;
|
|
146
151
|
/**
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
* Service override classes to import for side effects.
|
|
153
|
+
* These classes are imported to ensure their @Injectable decorators execute,
|
|
154
|
+
* allowing them to register with the DI system. Overrides should use the same
|
|
155
|
+
* InjectionToken as the original service with a higher priority.
|
|
156
|
+
*/
|
|
152
157
|
overrides?: ClassType[] | Set<ClassType>;
|
|
153
158
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
159
|
+
* Priority level for the module.
|
|
160
|
+
* Higher priority modules will be loaded first.
|
|
161
|
+
*/
|
|
157
162
|
priority?: number;
|
|
158
163
|
/**
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
164
|
+
* Registry to use for the module.
|
|
165
|
+
* Registry is used to store the module and its commands.
|
|
166
|
+
*/
|
|
162
167
|
registry?: Registry;
|
|
163
168
|
}
|
|
164
169
|
/**
|
|
@@ -206,7 +211,7 @@ declare function CliModule({
|
|
|
206
211
|
overrides,
|
|
207
212
|
priority,
|
|
208
213
|
registry
|
|
209
|
-
}?: CliModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
|
|
214
|
+
}?: CliModuleOptions): (target: ClassType, context: ClassDecoratorContext<abstract new (...args: any) => any>) => ClassType;
|
|
210
215
|
//#endregion
|
|
211
216
|
export { CommandHandler as a, CommandOptions as i, CliModuleOptions as n, Command as r, CliModule as t };
|
|
212
|
-
//# sourceMappingURL=cli-module.decorator-
|
|
217
|
+
//# sourceMappingURL=cli-module.decorator-BV3vVKlR.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-module.decorator-BV3vVKlR.d.cts","names":["CommandHandler","TOptions","Promise","InjectionToken","ClassType","ClassTypeWithInstance","Registry","z","CommandHandler","CommandOptions","ZodObject","Command","path","description","token","optionsSchema","priority","registry","ClassDecoratorContext","ClassType","Registry","CliModuleOptions","Set","CliModule","commands","controllers","imports","guards","overrides","priority","registry","ClassDecoratorContext"],"sources":["../src/interfaces/command-handler.interface.d.mts","../src/decorators/command.decorator.d.mts","../src/decorators/cli-module.decorator.d.mts"],"sourcesContent":["/**\n * Interface that all command classes must implement.\n *\n * Commands decorated with `@Command` must implement this interface.\n * The `execute` method is called when the command is invoked.\n *\n * @template TOptions - The type of options that the command accepts\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod/v4'\n *\n * const optionsSchema = z.object({\n * name: z.string()\n * })\n *\n * type Options = z.infer<typeof optionsSchema>\n *\n * @Command({ path: 'greet', optionsSchema })\n * export class GreetCommand implements CommandHandler<Options> {\n * async execute(options: Options, positionals?: string[]) {\n * console.log(`Hello, ${options.name}!`)\n * if (positionals?.length) {\n * console.log(`Files: ${positionals.join(', ')}`)\n * }\n * }\n * }\n * ```\n */\nexport interface CommandHandler<TOptions = any> {\n /**\n * Executes the command with the provided options and positional arguments.\n *\n * @param options - The validated command options (validated against the command's schema if provided)\n * @param positionals - Positional arguments that don't match any option flags\n * @returns A promise or void\n */\n execute(options: TOptions, positionals?: string[]): void | Promise<void>\n}\n//# sourceMappingURL=command-handler.interface.d.mts.map\n","import { InjectionToken } from '@navios/core'\n\nimport type { ClassType, ClassTypeWithInstance, Registry } from '@navios/core'\nimport type { z } from 'zod/v4'\n\nimport type { CommandHandler } from '../interfaces/index.mjs'\n/**\n * Options for the `@Command` decorator.\n *\n * @public\n */\nexport interface CommandOptions {\n /**\n * The token to use for the command.\n * If provided, the command will be registered with this token.\n */\n token?: InjectionToken<ClassTypeWithInstance<CommandHandler<any>>>\n /**\n * The command path that users will invoke from the CLI.\n * Can be a single word (e.g., 'greet') or multi-word with colons (e.g., 'user:create', 'db:migrate').\n */\n path: string\n /**\n * Optional description of the command for help text.\n * Displayed when users run `help` or `--help`.\n */\n description?: string\n /**\n * Optional zod/v4 schema for validating command options.\n * If provided, options will be validated and parsed according to this schema.\n */\n optionsSchema?: z.ZodObject\n /**\n * Priority level for the command.\n * Higher priority commands will be loaded first.\n */\n priority?: number\n /**\n * Registry to use for the command.\n * Registry is used to store the command and its options schema.\n */\n registry?: Registry\n}\n/**\n * Decorator that marks a class as a CLI command.\n *\n * The decorated class must implement the `CommandHandler` interface with an `execute` method.\n * The command will be automatically registered when its module is loaded.\n *\n * @param options - Configuration options for the command\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { Command, CommandHandler } from '@navios/commander'\n * import { z } from 'zod/v4'\n *\n * const optionsSchema = z.object({\n * name: z.string(),\n * greeting: z.string().optional().default('Hello')\n * })\n *\n * @Command({\n * path: 'greet',\n * optionsSchema: optionsSchema\n * })\n * export class GreetCommand implements CommandHandler<z.infer<typeof optionsSchema>> {\n * async execute(options) {\n * console.log(`${options.greeting}, ${options.name}!`)\n * }\n * }\n * ```\n */\nexport declare function Command({\n path,\n description,\n token,\n optionsSchema,\n priority,\n registry,\n}: CommandOptions): (\n target: ClassType,\n context: ClassDecoratorContext<abstract new (...args: any) => any>,\n) => any\n//# sourceMappingURL=command.decorator.d.mts.map\n","import type { ClassType, Registry } from '@navios/core'\n/**\n * Options for the `@CliModule` decorator.\n *\n * @public\n */\nexport interface CliModuleOptions {\n /**\n * Array or Set of command classes to register in this module.\n * Commands must be decorated with `@Command`.\n */\n commands?: ClassType[] | Set<ClassType>\n /**\n * Array or Set of controller classes for HTTP endpoints.\n * Allows mixing HTTP and CLI functionality in the same module.\n */\n controllers?: ClassType[] | Set<ClassType>\n /**\n * Array or Set of other modules to import.\n * Imported modules' commands and controllers will be available.\n */\n imports?: ClassType[] | Set<ClassType>\n /**\n * Guards to apply to all controllers in this module.\n * Guards are executed in reverse order (last guard first).\n */\n guards?: ClassType[] | Set<ClassType>\n /**\n * Service override classes to import for side effects.\n * These classes are imported to ensure their @Injectable decorators execute,\n * allowing them to register with the DI system. Overrides should use the same\n * InjectionToken as the original service with a higher priority.\n */\n overrides?: ClassType[] | Set<ClassType>\n /**\n * Priority level for the module.\n * Higher priority modules will be loaded first.\n */\n priority?: number\n /**\n * Registry to use for the module.\n * Registry is used to store the module and its commands.\n */\n registry?: Registry\n}\n/**\n * Decorator that marks a class as a CLI module.\n *\n * This decorator extends the standard @Module decorator, adding support for\n * CLI commands while maintaining full compatibility with HTTP controllers.\n * Modules organize commands and can import other modules to compose larger\n * CLI applications.\n *\n * The module can optionally implement `NaviosModule` interface for lifecycle hooks.\n *\n * @param options - Configuration options for the module\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { CliModule } from '@navios/commander'\n * import { GreetCommand } from './greet.command'\n * import { UserModule } from './user.module'\n *\n * @CliModule({\n * commands: [GreetCommand],\n * imports: [UserModule]\n * })\n * export class AppModule {}\n * ```\n *\n * @example\n * ```typescript\n * // Mixed HTTP and CLI module\n * @CliModule({\n * controllers: [HealthController],\n * commands: [MigrateCommand],\n * imports: [DatabaseModule],\n * })\n * export class AppModule {}\n * ```\n */\nexport declare function CliModule({\n commands,\n controllers,\n imports,\n guards,\n overrides,\n priority,\n registry,\n}?: CliModuleOptions): (\n target: ClassType,\n context: ClassDecoratorContext<abstract new (...args: any) => any>,\n) => ClassType\n//# sourceMappingURL=cli-module.decorator.d.mts.map\n"],"mappings":";;;;;;;;;AA8BA;;;;ACnBA;;;;;;;AA8DA;;;;;;;;;;;;;;ACnEA;AAKamB,UFmBInB,cEnBJmB,CAAAA,WAAAA,GAAAA,CAAAA,CAAAA;EAAkBA;;;;;;;EAULG,OAAAA,CAAAA,OAAAA,EFiBPrB,QEjBOqB,EAAAA,WAAAA,CAAAA,EAAAA,MAAAA,EAAAA,CAAAA,EAAAA,IAAAA,GFiBmCpB,OEjBnCoB,CAAAA,IAAAA,CAAAA;;;;;;ADV1B;;;AAKUnB,UALOM,cAAAA,CAKPN;EAeQI;;;AA0ClB;EACEK,KAAAA,CAAAA,EA1DQT,cA0DRS,CA1DuBP,qBA0DvBO,CA1D6CJ,cA0D7CI,CAAAA,GAAAA,CAAAA,CAAAA,CAAAA;EACAC;;;;EAIAI,IAAAA,EAAAA,MAAAA;EACCR;;;;;;;AC1EH;;EAK+BU,aAAAA,CAAAA,EDoBbZ,CAAAA,CAAEG,SCpBWS;EAAJG;;;;EAUfH,QAAAA,CAAAA,EAAAA,MAAAA;EAAkBA;;;;EAKLG,QAAAA,CAAAA,EDeZhB,QCfYgB;;;;;;AAwDzB;;;;;;;;;;;;;;;;;;;;;;;;;;iBDTwBX,OAAAA;;;;;;;GAOrBF,0BACOL,oBACCc;;;;;;ADpDX;;UExBiBG,gBAAAA;;ADKjB;;;EAKUlB,QAAAA,CAAAA,ECLGgB,SDKHhB,EAAAA,GCLiBmB,GDKjBnB,CCLqBgB,SDKrBhB,CAAAA;EAeQI;;;AA0ClB;EACEK,WAAAA,CAAAA,EC1DcO,SD0DdP,EAAAA,GC1D4BU,GD0D5BV,CC1DgCO,SD0DhCP,CAAAA;EACAC;;;;EAIAI,OAAAA,CAAAA,EC1DUE,SD0DVF,EAAAA,GC1DwBK,GD0DxBL,CC1D4BE,SD0D5BF,CAAAA;EACCR;;;;WCtDQU,cAAcG,IAAIH;;;AApB7B;;;;EAUgBA,SAAAA,CAAAA,EAiBFA,SAjBEA,EAAAA,GAiBYG,GAjBZH,CAiBgBA,SAjBhBA,CAAAA;EAAkBA;;;;EAKRG,QAAAA,CAAAA,EAAAA,MAAAA;EAKfH;;;;EAOqBA,QAAAA,CAAAA,EAUnBC,QAVmBD;;;;AAiDhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAwBI,SAAAA;;;;;;;;IAQpBF,4BACMF,oBACCY,8DACNZ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_command_decorator = require('./command.decorator-
|
|
1
|
+
const require_command_decorator = require('./command.decorator-HziankUv.cjs');
|
|
2
2
|
let _navios_core = require("@navios/core");
|
|
3
3
|
|
|
4
4
|
//#region src/decorators/cli-module.decorator.mts
|
|
@@ -68,4 +68,4 @@ Object.defineProperty(exports, 'CliModule', {
|
|
|
68
68
|
return CliModule;
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
-
//# sourceMappingURL=cli-module.decorator-
|
|
71
|
+
//# sourceMappingURL=cli-module.decorator-CXt38aqF.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-module.decorator-CXt38aqF.cjs","names":["Module","getModuleMetadata","getModuleCustomEntry","CommandEntryKey","CliModule","commands","controllers","imports","guards","overrides","priority","registry","target","context","kind","Error","result","metadata","commandSet","Set","command","add"],"sources":["../src/decorators/cli-module.decorator.mts"],"sourcesContent":["import { Module, getModuleMetadata, getModuleCustomEntry } from '@navios/core'\n\nimport type { ClassType, Registry } from '@navios/core'\n\nimport { CommandEntryKey, type CommandEntryValue } from '../metadata/command-entry.metadata.mjs'\n\n/**\n * Options for the `@CliModule` decorator.\n *\n * @public\n */\nexport interface CliModuleOptions {\n /**\n * Array or Set of command classes to register in this module.\n * Commands must be decorated with `@Command`.\n */\n commands?: ClassType[] | Set<ClassType>\n /**\n * Array or Set of controller classes for HTTP endpoints.\n * Allows mixing HTTP and CLI functionality in the same module.\n */\n controllers?: ClassType[] | Set<ClassType>\n /**\n * Array or Set of other modules to import.\n * Imported modules' commands and controllers will be available.\n */\n imports?: ClassType[] | Set<ClassType>\n /**\n * Guards to apply to all controllers in this module.\n * Guards are executed in reverse order (last guard first).\n */\n guards?: ClassType[] | Set<ClassType>\n /**\n * Service override classes to import for side effects.\n * These classes are imported to ensure their @Injectable decorators execute,\n * allowing them to register with the DI system. Overrides should use the same\n * InjectionToken as the original service with a higher priority.\n */\n overrides?: ClassType[] | Set<ClassType>\n /**\n * Priority level for the module.\n * Higher priority modules will be loaded first.\n */\n priority?: number\n /**\n * Registry to use for the module.\n * Registry is used to store the module and its commands.\n */\n registry?: Registry\n}\n\n/**\n * Decorator that marks a class as a CLI module.\n *\n * This decorator extends the standard @Module decorator, adding support for\n * CLI commands while maintaining full compatibility with HTTP controllers.\n * Modules organize commands and can import other modules to compose larger\n * CLI applications.\n *\n * The module can optionally implement `NaviosModule` interface for lifecycle hooks.\n *\n * @param options - Configuration options for the module\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { CliModule } from '@navios/commander'\n * import { GreetCommand } from './greet.command'\n * import { UserModule } from './user.module'\n *\n * @CliModule({\n * commands: [GreetCommand],\n * imports: [UserModule]\n * })\n * export class AppModule {}\n * ```\n *\n * @example\n * ```typescript\n * // Mixed HTTP and CLI module\n * @CliModule({\n * controllers: [HealthController],\n * commands: [MigrateCommand],\n * imports: [DatabaseModule],\n * })\n * export class AppModule {}\n * ```\n */\nexport function CliModule(\n {\n commands = [],\n controllers = [],\n imports = [],\n guards = [],\n overrides = [],\n priority,\n registry,\n }: CliModuleOptions = {\n commands: [],\n controllers: [],\n imports: [],\n guards: [],\n overrides: [],\n },\n) {\n return (target: ClassType, context: ClassDecoratorContext) => {\n if (context.kind !== 'class') {\n throw new Error('[Navios Commander] @CliModule decorator can only be used on classes.')\n }\n\n // Apply standard @Module decorator first\n const result = Module({\n controllers,\n imports,\n guards,\n overrides,\n priority,\n registry,\n })(target, context)\n\n // Get the module metadata that @Module just created\n const metadata = getModuleMetadata(target, context)\n\n // Store commands in customEntries\n const commandSet = getModuleCustomEntry<CommandEntryValue>(\n metadata,\n CommandEntryKey,\n () => new Set(),\n )\n for (const command of commands) {\n commandSet.add(command)\n }\n\n return result\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFA,SAAgBI,UACd,EACEC,WAAW,EAAE,EACbC,cAAc,EAAE,EAChBC,UAAU,EAAE,EACZC,SAAS,EAAE,EACXC,YAAY,EAAE,EACdC,UACAC,aACoB;CACpBN,UAAU,EAAE;CACZC,aAAa,EAAE;CACfC,SAAS,EAAE;CACXC,QAAQ,EAAE;CACVC,WAAW,EAAE;CACd,EAAA;AAED,SAAQG,QAAmBC,YAAAA;AACzB,MAAIA,QAAQC,SAAS,QACnB,OAAM,IAAIC,MAAM,uEAAA;EAIlB,MAAMC,kCAAgB;GACpBV;GACAC;GACAC;GACAC;GACAC;GACAC;GACF,CAAA,CAAGC,QAAQC,QAAAA;EAMX,MAAMK,wFAH6BN,QAAQC,QAAAA,EAKzCV,iEACM,IAAIgB,KAAAA,CAAAA;AAEZ,OAAK,MAAMC,WAAWf,SACpBa,YAAWG,IAAID,QAAAA;AAGjB,SAAOJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as CommandEntryKey } from "./command.decorator-
|
|
1
|
+
import { n as CommandEntryKey } from "./command.decorator-QiRU7ny3.mjs";
|
|
2
2
|
import { Module, getModuleCustomEntry, getModuleMetadata } from "@navios/core";
|
|
3
3
|
|
|
4
4
|
//#region src/decorators/cli-module.decorator.mts
|
|
@@ -63,4 +63,4 @@ import { Module, getModuleCustomEntry, getModuleMetadata } from "@navios/core";
|
|
|
63
63
|
|
|
64
64
|
//#endregion
|
|
65
65
|
export { CliModule as t };
|
|
66
|
-
//# sourceMappingURL=cli-module.decorator-
|
|
66
|
+
//# sourceMappingURL=cli-module.decorator-DAjf_r_W.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-module.decorator-DAjf_r_W.mjs","names":["Module","getModuleMetadata","getModuleCustomEntry","CommandEntryKey","CliModule","commands","controllers","imports","guards","overrides","priority","registry","target","context","kind","Error","result","metadata","commandSet","Set","command","add"],"sources":["../src/decorators/cli-module.decorator.mts"],"sourcesContent":["import { Module, getModuleMetadata, getModuleCustomEntry } from '@navios/core'\n\nimport type { ClassType, Registry } from '@navios/core'\n\nimport { CommandEntryKey, type CommandEntryValue } from '../metadata/command-entry.metadata.mjs'\n\n/**\n * Options for the `@CliModule` decorator.\n *\n * @public\n */\nexport interface CliModuleOptions {\n /**\n * Array or Set of command classes to register in this module.\n * Commands must be decorated with `@Command`.\n */\n commands?: ClassType[] | Set<ClassType>\n /**\n * Array or Set of controller classes for HTTP endpoints.\n * Allows mixing HTTP and CLI functionality in the same module.\n */\n controllers?: ClassType[] | Set<ClassType>\n /**\n * Array or Set of other modules to import.\n * Imported modules' commands and controllers will be available.\n */\n imports?: ClassType[] | Set<ClassType>\n /**\n * Guards to apply to all controllers in this module.\n * Guards are executed in reverse order (last guard first).\n */\n guards?: ClassType[] | Set<ClassType>\n /**\n * Service override classes to import for side effects.\n * These classes are imported to ensure their @Injectable decorators execute,\n * allowing them to register with the DI system. Overrides should use the same\n * InjectionToken as the original service with a higher priority.\n */\n overrides?: ClassType[] | Set<ClassType>\n /**\n * Priority level for the module.\n * Higher priority modules will be loaded first.\n */\n priority?: number\n /**\n * Registry to use for the module.\n * Registry is used to store the module and its commands.\n */\n registry?: Registry\n}\n\n/**\n * Decorator that marks a class as a CLI module.\n *\n * This decorator extends the standard @Module decorator, adding support for\n * CLI commands while maintaining full compatibility with HTTP controllers.\n * Modules organize commands and can import other modules to compose larger\n * CLI applications.\n *\n * The module can optionally implement `NaviosModule` interface for lifecycle hooks.\n *\n * @param options - Configuration options for the module\n * @returns A class decorator function\n *\n * @example\n * ```typescript\n * import { CliModule } from '@navios/commander'\n * import { GreetCommand } from './greet.command'\n * import { UserModule } from './user.module'\n *\n * @CliModule({\n * commands: [GreetCommand],\n * imports: [UserModule]\n * })\n * export class AppModule {}\n * ```\n *\n * @example\n * ```typescript\n * // Mixed HTTP and CLI module\n * @CliModule({\n * controllers: [HealthController],\n * commands: [MigrateCommand],\n * imports: [DatabaseModule],\n * })\n * export class AppModule {}\n * ```\n */\nexport function CliModule(\n {\n commands = [],\n controllers = [],\n imports = [],\n guards = [],\n overrides = [],\n priority,\n registry,\n }: CliModuleOptions = {\n commands: [],\n controllers: [],\n imports: [],\n guards: [],\n overrides: [],\n },\n) {\n return (target: ClassType, context: ClassDecoratorContext) => {\n if (context.kind !== 'class') {\n throw new Error('[Navios Commander] @CliModule decorator can only be used on classes.')\n }\n\n // Apply standard @Module decorator first\n const result = Module({\n controllers,\n imports,\n guards,\n overrides,\n priority,\n registry,\n })(target, context)\n\n // Get the module metadata that @Module just created\n const metadata = getModuleMetadata(target, context)\n\n // Store commands in customEntries\n const commandSet = getModuleCustomEntry<CommandEntryValue>(\n metadata,\n CommandEntryKey,\n () => new Set(),\n )\n for (const command of commands) {\n commandSet.add(command)\n }\n\n return result\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFA,SAAgBI,UACd,EACEC,WAAW,EAAE,EACbC,cAAc,EAAE,EAChBC,UAAU,EAAE,EACZC,SAAS,EAAE,EACXC,YAAY,EAAE,EACdC,UACAC,aACoB;CACpBN,UAAU,EAAE;CACZC,aAAa,EAAE;CACfC,SAAS,EAAE;CACXC,QAAQ,EAAE;CACVC,WAAW,EAAE;CACd,EAAA;AAED,SAAQG,QAAmBC,YAAAA;AACzB,MAAIA,QAAQC,SAAS,QACnB,OAAM,IAAIC,MAAM,uEAAA;EAIlB,MAAMC,SAAShB,OAAO;GACpBM;GACAC;GACAC;GACAC;GACAC;GACAC;GACF,CAAA,CAAGC,QAAQC,QAAAA;EAMX,MAAMK,aAAahB,qBAHFD,kBAAkBW,QAAQC,QAAAA,EAKzCV,uCACM,IAAIgB,KAAAA,CAAAA;AAEZ,OAAK,MAAMC,WAAWf,SACpBa,YAAWG,IAAID,QAAAA;AAGjB,SAAOJ"}
|