@navios/commander 1.4.0 → 1.5.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.
- package/.turbo/turbo-build.log +49 -0
- package/.turbo/turbo-check.log +2 -0
- package/.turbo/turbo-lint.log +3 -0
- package/.turbo/turbo-test$colon$ci.log +117 -0
- package/CHANGELOG.md +9 -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 +9 -9
- package/dist/src/interfaces/commander-execution-context.interface.d.mts +30 -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 +49 -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-DVl8009Q.d.cts → cli-module.decorator-BzsOEMPH.d.cts} +8 -8
- package/lib/cli-module.decorator-BzsOEMPH.d.cts.map +1 -0
- package/lib/{cli-module.decorator-DGuGfpex.d.mts → cli-module.decorator-CCV_elPP.d.mts} +13 -13
- package/lib/cli-module.decorator-CCV_elPP.d.mts.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/{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 +103 -103
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +95 -95
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.mts +90 -90
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +102 -102
- 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 +2 -2
- package/lib/legacy-compat/index.d.cts.map +1 -1
- package/lib/legacy-compat/index.d.mts +2 -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 +22 -66
- package/src/commander.factory.mts +3 -1
- 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 +1 -1
- package/src/interfaces/commander-execution-context.interface.mts +1 -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 +10 -27
- package/src/tokens/execution-context.token.mts +4 -6
- package/tsconfig.json +3 -0
- package/lib/cli-module.decorator-CkP22084.cjs.map +0 -1
- package/lib/cli-module.decorator-DGuGfpex.d.mts.map +0 -1
- package/lib/cli-module.decorator-DVl8009Q.d.cts.map +0 -1
- package/lib/cli-module.decorator-UGbtkRYc.mjs.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
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { ClassType } from '@navios/core'
|
|
1
|
+
import type { ClassType } from '@navios/core'
|
|
2
2
|
/**
|
|
3
3
|
* Symbol key for storing commands in ModuleMetadata.customEntries.
|
|
4
4
|
* Used by @CliModule to store command classes.
|
|
5
5
|
*
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export declare const CommandEntryKey: unique symbol
|
|
8
|
+
export declare const CommandEntryKey: unique symbol
|
|
9
9
|
/**
|
|
10
10
|
* Type for the command entry value stored in customEntries.
|
|
11
11
|
*
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
|
-
export type CommandEntryValue = Set<ClassType
|
|
14
|
+
export type CommandEntryValue = Set<ClassType>
|
|
15
15
|
/**
|
|
16
16
|
* Extracts commands from a module's metadata.
|
|
17
17
|
* Returns empty set if no commands are defined.
|
|
@@ -27,5 +27,5 @@ export type CommandEntryValue = Set<ClassType>;
|
|
|
27
27
|
* }
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare function extractModuleCommands(moduleClass: ClassType): Set<ClassType
|
|
31
|
-
//# sourceMappingURL=command-entry.metadata.d.mts.map
|
|
30
|
+
export declare function extractModuleCommands(moduleClass: ClassType): Set<ClassType>
|
|
31
|
+
//# sourceMappingURL=command-entry.metadata.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.metadata.d.mts","sourceRoot":"","sources":["../../../src/metadata/command-entry.metadata.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-entry.metadata.d.mts","sourceRoot":"","sources":["../../../src/metadata/command-entry.metadata.mts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,eAAe,eAA4B,CAAA;AAExD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,SAAS,CAAC,CAAA;AAE9C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC,CAG5E"}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import type { ClassType } from '@navios/core'
|
|
2
|
-
import type {
|
|
1
|
+
import type { ClassType } from '@navios/core'
|
|
2
|
+
import type { z } from 'zod/v4'
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
* Symbol key used to store command metadata on classes.
|
|
6
6
|
*/
|
|
7
|
-
export declare const CommandMetadataKey: unique symbol
|
|
7
|
+
export declare const CommandMetadataKey: unique symbol
|
|
8
8
|
/**
|
|
9
9
|
* Metadata associated with a command.
|
|
10
10
|
*
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
13
13
|
export interface CommandMetadata {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The command path (e.g., 'greet', 'user:create').
|
|
16
|
+
*/
|
|
17
|
+
path: string
|
|
18
|
+
/**
|
|
19
|
+
* Optional description of the command for help text.
|
|
20
|
+
*/
|
|
21
|
+
description?: string
|
|
22
|
+
/**
|
|
23
|
+
* Optional zod/v4 schema for validating command options.
|
|
24
|
+
*/
|
|
25
|
+
optionsSchema?: z.ZodObject
|
|
26
|
+
/**
|
|
27
|
+
* Map of custom attributes that can be attached to the command.
|
|
28
|
+
*/
|
|
29
|
+
customAttributes: Map<string | symbol, any>
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Gets or creates command metadata for a class.
|
|
@@ -36,10 +36,16 @@ export interface CommandMetadata {
|
|
|
36
36
|
* @param context - The decorator context
|
|
37
37
|
* @param path - The command path
|
|
38
38
|
* @param description - Optional description for help text
|
|
39
|
-
* @param optionsSchema - Optional
|
|
39
|
+
* @param optionsSchema - Optional zod/v4 schema
|
|
40
40
|
* @returns The command metadata
|
|
41
41
|
*/
|
|
42
|
-
export declare function getCommandMetadata(
|
|
42
|
+
export declare function getCommandMetadata(
|
|
43
|
+
target: ClassType,
|
|
44
|
+
context: ClassDecoratorContext,
|
|
45
|
+
path: string,
|
|
46
|
+
description?: string,
|
|
47
|
+
optionsSchema?: z.ZodObject,
|
|
48
|
+
): CommandMetadata
|
|
43
49
|
/**
|
|
44
50
|
* Extracts command metadata from a class.
|
|
45
51
|
*
|
|
@@ -53,12 +59,12 @@ export declare function getCommandMetadata(target: ClassType, context: ClassDeco
|
|
|
53
59
|
* console.log(metadata.path) // 'greet'
|
|
54
60
|
* ```
|
|
55
61
|
*/
|
|
56
|
-
export declare function extractCommandMetadata(target: ClassType): CommandMetadata
|
|
62
|
+
export declare function extractCommandMetadata(target: ClassType): CommandMetadata
|
|
57
63
|
/**
|
|
58
64
|
* Checks if a class has command metadata.
|
|
59
65
|
*
|
|
60
66
|
* @param target - The class to check
|
|
61
67
|
* @returns `true` if the class is decorated with @Command, `false` otherwise
|
|
62
68
|
*/
|
|
63
|
-
export declare function hasCommandMetadata(target: ClassType): boolean
|
|
64
|
-
//# sourceMappingURL=command.metadata.d.mts.map
|
|
69
|
+
export declare function hasCommandMetadata(target: ClassType): boolean
|
|
70
|
+
//# sourceMappingURL=command.metadata.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.metadata.d.mts","sourceRoot":"","sources":["../../../src/metadata/command.metadata.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"command.metadata.d.mts","sourceRoot":"","sources":["../../../src/metadata/command.metadata.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;GAGG;AACH,eAAO,MAAM,kBAAkB,eAA+B,CAAA;AAE9D;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,CAAC,SAAS,CAAA;IAC3B;;OAEG;IACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,qBAAqB,EAC9B,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,CAAC,CAAC,SAAS,GAC1B,eAAe,CAmBjB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,eAAe,CASzE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAI7D"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './command.metadata.mjs'
|
|
2
|
-
export * from './command-entry.metadata.mjs'
|
|
3
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
export * from './command.metadata.mjs'
|
|
2
|
+
export * from './command-entry.metadata.mjs'
|
|
3
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { z } from 'zod/v4'
|
|
2
|
+
|
|
3
|
+
import type { CommandHandler } from '../interfaces/command-handler.interface.mjs'
|
|
4
|
+
declare const helpOptionsSchema: z.ZodObject<
|
|
5
|
+
{
|
|
6
|
+
command: z.ZodOptional<z.ZodString>
|
|
7
|
+
},
|
|
8
|
+
z.core.$strip
|
|
9
|
+
>
|
|
10
|
+
type HelpOptions = z.infer<typeof helpOptionsSchema>
|
|
7
11
|
/**
|
|
8
12
|
* Built-in help command that lists all available commands or shows help for a specific command.
|
|
9
13
|
*
|
|
10
14
|
* @public
|
|
11
15
|
*/
|
|
12
16
|
export declare class HelpCommand implements CommandHandler<HelpOptions> {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
private logger
|
|
18
|
+
private commandRegistry
|
|
19
|
+
execute(options: HelpOptions): Promise<void>
|
|
16
20
|
}
|
|
17
|
-
export {}
|
|
18
|
-
//# sourceMappingURL=help.command.d.mts.map
|
|
21
|
+
export {}
|
|
22
|
+
//# sourceMappingURL=help.command.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.command.d.mts","sourceRoot":"","sources":["../../../src/overrides/help.command.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"help.command.d.mts","sourceRoot":"","sources":["../../../src/overrides/help.command.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAM1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AAEjF,QAAA,MAAM,iBAAiB;;iBAErB,CAAA;AAEF,KAAK,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEpD;;;;GAIG;AACH,qBAOa,WAAY,YAAW,cAAc,CAAC,WAAW,CAAC;IAC7D,OAAO,CAAC,MAAM,CAA4D;IAC1E,OAAO,CAAC,eAAe,CAAiC;IAElD,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAMjD;CACF"}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { z } from 'zod/v4'
|
|
2
2
|
/**
|
|
3
3
|
* Result of parsing command-line arguments.
|
|
4
4
|
*
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
7
|
export interface ParsedCliArgs {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The command path (e.g., 'greet', 'user:create').
|
|
10
|
+
* Multi-word commands are joined with spaces.
|
|
11
|
+
*/
|
|
12
|
+
command: string
|
|
13
|
+
/**
|
|
14
|
+
* Parsed options as key-value pairs.
|
|
15
|
+
* Keys are converted from kebab-case to camelCase.
|
|
16
|
+
*/
|
|
17
|
+
options: Record<string, any>
|
|
18
|
+
/**
|
|
19
|
+
* Positional arguments that don't match any option flags.
|
|
20
|
+
*/
|
|
21
|
+
positionals: string[]
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Service for parsing command-line arguments.
|
|
@@ -33,43 +33,43 @@ export interface ParsedCliArgs {
|
|
|
33
33
|
* @public
|
|
34
34
|
*/
|
|
35
35
|
export declare class CliParserService {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Parses command-line arguments from process.argv
|
|
38
|
+
* Commands can be multi-word (e.g., 'db migrate', 'cache clear')
|
|
39
|
+
* Expected format: node script.js command [subcommand...] --flag value --boolean-flag positional1 positional2
|
|
40
|
+
*
|
|
41
|
+
* @param argv - Array of command-line arguments (typically process.argv)
|
|
42
|
+
* @param optionsSchema - Optional zod/v4 schema to determine boolean flags and option types
|
|
43
|
+
* @returns Parsed command (space-separated if multi-word), options, and positional arguments
|
|
44
|
+
*/
|
|
45
|
+
parse(argv: string[], optionsSchema?: z.ZodObject): ParsedCliArgs
|
|
46
|
+
/**
|
|
47
|
+
* Converts kebab-case to camelCase
|
|
48
|
+
*/
|
|
49
|
+
private camelCase
|
|
50
|
+
/**
|
|
51
|
+
* Attempts to parse string values into appropriate types
|
|
52
|
+
*/
|
|
53
|
+
private parseValue
|
|
54
|
+
/**
|
|
55
|
+
* Extracts boolean field names from a zod/v4 schema
|
|
56
|
+
* Handles z.ZodObject, zod/v4Optional, and zod/v4Default wrappers
|
|
57
|
+
*/
|
|
58
|
+
private extractBooleanFields
|
|
59
|
+
/**
|
|
60
|
+
* Extracts array field names from a zod/v4 schema
|
|
61
|
+
* Handles z.ZodObject, zod/v4Optional, and zod/v4Default wrappers
|
|
62
|
+
*/
|
|
63
|
+
private extractArrayFields
|
|
64
|
+
/**
|
|
65
|
+
* Checks if a zod/v4 schema represents a boolean type
|
|
66
|
+
* Unwraps zod/v4Optional and zod/v4Default using zod/v4 v4 API
|
|
67
|
+
*/
|
|
68
|
+
private isSchemaBoolean
|
|
69
|
+
/**
|
|
70
|
+
* Checks if a zod/v4 schema represents an array type
|
|
71
|
+
* Unwraps zod/v4Optional and zod/v4Default using zod/v4 v4 API
|
|
72
|
+
*/
|
|
73
|
+
private isSchemaArray
|
|
74
74
|
}
|
|
75
|
-
//# sourceMappingURL=cli-parser.service.d.mts.map
|
|
75
|
+
//# sourceMappingURL=cli-parser.service.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-parser.service.d.mts","sourceRoot":"","sources":["../../../src/services/cli-parser.service.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-parser.service.d.mts","sourceRoot":"","sources":["../../../src/services/cli-parser.service.mts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5B;;OAEG;IACH,WAAW,EAAE,MAAM,EAAE,CAAA;CACtB;AAED;;;;;;;;;;;GAWG;AACH,qBACa,gBAAgB;IAC3B;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,SAAS,GAAG,aAAa,CAiIhE;IAED;;OAEG;IACH,OAAO,CAAC,SAAS;IAIjB;;OAEG;IACH,OAAO,CAAC,UAAU;IAkClB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IA0B5B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAwB1B;;;OAGG;IACH,OAAO,CAAC,eAAe;IAiBvB;;;OAGG;IACH,OAAO,CAAC,aAAa;CAgBtB"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import type { ClassType } from '@navios/core'
|
|
2
|
-
|
|
1
|
+
import type { ClassType } from '@navios/core'
|
|
2
|
+
|
|
3
|
+
import type { CommandMetadata } from '../metadata/index.mjs'
|
|
3
4
|
/**
|
|
4
5
|
* Represents a registered command with its metadata and module information.
|
|
5
6
|
*
|
|
6
7
|
* @public
|
|
7
8
|
*/
|
|
8
9
|
export interface RegisteredCommand {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The command class
|
|
12
|
+
*/
|
|
13
|
+
class: ClassType
|
|
14
|
+
/**
|
|
15
|
+
* The command metadata from @Command decorator
|
|
16
|
+
*/
|
|
17
|
+
metadata: CommandMetadata
|
|
18
|
+
/**
|
|
19
|
+
* Name of the module this command belongs to
|
|
20
|
+
*/
|
|
21
|
+
moduleName: string
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* Service for registering and looking up CLI commands.
|
|
@@ -26,64 +27,64 @@ export interface RegisteredCommand {
|
|
|
26
27
|
* @public
|
|
27
28
|
*/
|
|
28
29
|
export declare class CommandRegistryService {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
30
|
+
private commands
|
|
31
|
+
/**
|
|
32
|
+
* Register a command with its metadata.
|
|
33
|
+
*
|
|
34
|
+
* @param path - The command path (e.g., 'greet', 'user:create')
|
|
35
|
+
* @param command - The registered command data
|
|
36
|
+
* @throws Error if a command with the same path is already registered
|
|
37
|
+
*/
|
|
38
|
+
register(path: string, command: RegisteredCommand): void
|
|
39
|
+
/**
|
|
40
|
+
* Get a command by its path.
|
|
41
|
+
*
|
|
42
|
+
* @param path - The command path
|
|
43
|
+
* @returns The registered command or undefined if not found
|
|
44
|
+
*/
|
|
45
|
+
getByPath(path: string): RegisteredCommand | undefined
|
|
46
|
+
/**
|
|
47
|
+
* Get all registered commands.
|
|
48
|
+
*
|
|
49
|
+
* @returns Map of path to registered command
|
|
50
|
+
*/
|
|
51
|
+
getAll(): Map<string, RegisteredCommand>
|
|
52
|
+
/**
|
|
53
|
+
* Get all registered commands as an array of path and class pairs.
|
|
54
|
+
* Useful for listing available commands.
|
|
55
|
+
*
|
|
56
|
+
* @returns Array of objects containing path and class
|
|
57
|
+
*/
|
|
58
|
+
getAllAsArray(): Array<{
|
|
59
|
+
path: string
|
|
60
|
+
class: ClassType
|
|
61
|
+
}>
|
|
62
|
+
/**
|
|
63
|
+
* Formats help text listing all available commands with descriptions.
|
|
64
|
+
*
|
|
65
|
+
* @returns Formatted string listing all commands
|
|
66
|
+
*/
|
|
67
|
+
formatCommandList(): string
|
|
68
|
+
/**
|
|
69
|
+
* Formats help text for a specific command.
|
|
70
|
+
*
|
|
71
|
+
* @param commandPath - The command path to show help for
|
|
72
|
+
* @returns Formatted string with command help
|
|
73
|
+
*/
|
|
74
|
+
formatCommandHelp(commandPath: string): string
|
|
75
|
+
/**
|
|
76
|
+
* Gets a human-readable type name from a zod/v4 schema.
|
|
77
|
+
*/
|
|
78
|
+
private getSchemaTypeName
|
|
79
|
+
/**
|
|
80
|
+
* Gets metadata from a zod/v4 schema, traversing innerType if needed.
|
|
81
|
+
* zod/v4 v4 stores meta at the outermost layer when .meta() is called last,
|
|
82
|
+
* or in innerType when .meta() is called before .optional()/.default().
|
|
83
|
+
*/
|
|
84
|
+
private getSchemaMeta
|
|
85
|
+
/**
|
|
86
|
+
* Clear all registered commands.
|
|
87
|
+
*/
|
|
88
|
+
clear(): void
|
|
88
89
|
}
|
|
89
|
-
//# sourceMappingURL=command-registry.service.d.mts.map
|
|
90
|
+
//# sourceMappingURL=command-registry.service.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-registry.service.d.mts","sourceRoot":"","sources":["../../../src/services/command-registry.service.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-registry.service.d.mts","sourceRoot":"","sources":["../../../src/services/command-registry.service.mts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,KAAK,EAAE,SAAS,CAAA;IAChB;;OAEG;IACH,QAAQ,EAAE,eAAe,CAAA;IACzB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;;;;GAKG;AACH,qBACa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAuC;IAEvD;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAKvD;IAED;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAErD;IAED;;;;OAIG;IACH,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAEvC;IAED;;;;;OAKG;IACH,aAAa,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC,CAMzD;IAED;;;;OAIG;IACH,iBAAiB,IAAI,MAAM,CAW1B;IAED;;;;;OAKG;IACH,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAoC7C;IAED;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAuCzB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAkBrB;;OAEG;IACH,KAAK,IAAI,IAAI,CAEZ;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ClassType, ModuleMetadata } from '@navios/core'
|
|
2
|
-
|
|
3
|
-
import type {
|
|
1
|
+
import type { ClassType, ModuleMetadata } from '@navios/core'
|
|
2
|
+
|
|
3
|
+
import type { AbstractCliAdapterInterface } from '../interfaces/abstract-cli-adapter.interface.mjs'
|
|
4
|
+
import type { CliAdapterOptions } from '../interfaces/environment.interface.mjs'
|
|
4
5
|
/**
|
|
5
6
|
* CLI adapter service that implements the AbstractCliAdapterInterface.
|
|
6
7
|
* Handles command discovery, registration, parsing, and execution.
|
|
@@ -8,49 +9,49 @@ import type { CliAdapterOptions } from '../interfaces/environment.interface.mjs'
|
|
|
8
9
|
* @public
|
|
9
10
|
*/
|
|
10
11
|
export declare class CommanderAdapterService implements AbstractCliAdapterInterface {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
12
|
+
private container
|
|
13
|
+
private commandRegistry
|
|
14
|
+
private cliParser
|
|
15
|
+
private logger
|
|
16
|
+
private options
|
|
17
|
+
private isReady
|
|
18
|
+
/**
|
|
19
|
+
* Sets up the adapter with the provided options.
|
|
20
|
+
* Called during application initialization.
|
|
21
|
+
*/
|
|
22
|
+
setupAdapter(options: CliAdapterOptions): Promise<void>
|
|
23
|
+
/**
|
|
24
|
+
* Called after all modules are loaded.
|
|
25
|
+
* Iterates through modules and extracts commands from customEntries.
|
|
26
|
+
*/
|
|
27
|
+
onModulesInit(modules: Map<string, ModuleMetadata>): Promise<void>
|
|
28
|
+
/**
|
|
29
|
+
* Registers built-in commands like help.
|
|
30
|
+
*/
|
|
31
|
+
private registerBuiltInCommands
|
|
32
|
+
/**
|
|
33
|
+
* Signals that the adapter is ready to handle commands.
|
|
34
|
+
*/
|
|
35
|
+
ready(): Promise<void>
|
|
36
|
+
/**
|
|
37
|
+
* Disposes of the adapter and cleans up resources.
|
|
38
|
+
*/
|
|
39
|
+
dispose(): Promise<void>
|
|
40
|
+
/**
|
|
41
|
+
* Run the CLI application with the given arguments.
|
|
42
|
+
* Parses arguments and executes the matching command.
|
|
43
|
+
*/
|
|
44
|
+
run(argv?: string[]): Promise<void>
|
|
45
|
+
/**
|
|
46
|
+
* Execute a command programmatically with the provided options.
|
|
47
|
+
*/
|
|
48
|
+
executeCommand(path: string, options?: Record<string, unknown>): Promise<void>
|
|
49
|
+
/**
|
|
50
|
+
* Get all registered command paths and their class references.
|
|
51
|
+
*/
|
|
52
|
+
getAllCommands(): Array<{
|
|
53
|
+
path: string
|
|
54
|
+
class: ClassType
|
|
55
|
+
}>
|
|
55
56
|
}
|
|
56
|
-
//# sourceMappingURL=commander-adapter.service.d.mts.map
|
|
57
|
+
//# sourceMappingURL=commander-adapter.service.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commander-adapter.service.d.mts","sourceRoot":"","sources":["../../../src/services/commander-adapter.service.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commander-adapter.service.d.mts","sourceRoot":"","sources":["../../../src/services/commander-adapter.service.mts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAQ7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAA;AAEnG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAMhF;;;;;GAKG;AACH,qBACa,uBAAwB,YAAW,2BAA2B;IACzE,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,eAAe,CAAiC;IACxD,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,MAAM,CAA2C;IAEzD,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,OAAO,CAAQ;IAEvB;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5D;IAED;;;OAGG;IACG,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBvE;IAED;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAS/B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAG7B;IAED;;;OAGG;IACG,GAAG,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCtD;IAED;;OAEG;IACG,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCvF;IAED;;OAEG;IACH,cAAc,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC,CAE1D;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './cli-parser.service.mjs'
|
|
2
|
-
export * from './command-registry.service.mjs'
|
|
3
|
-
export * from './commander-adapter.service.mjs'
|
|
4
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
export * from './cli-parser.service.mjs'
|
|
2
|
+
export * from './command-registry.service.mjs'
|
|
3
|
+
export * from './commander-adapter.service.mjs'
|
|
4
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { InjectionToken } from '@navios/core'
|
|
2
|
-
|
|
1
|
+
import { InjectionToken } from '@navios/core'
|
|
2
|
+
|
|
3
|
+
import type { CommanderExecutionContext } from '../interfaces/index.mjs'
|
|
3
4
|
/**
|
|
4
5
|
* Injection token for accessing the current command execution context.
|
|
5
6
|
*
|
|
@@ -23,5 +24,9 @@ import type { CommanderExecutionContext } from '../interfaces/index.mjs';
|
|
|
23
24
|
* }
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
|
-
export declare const CommandExecutionContext: InjectionToken<
|
|
27
|
-
|
|
27
|
+
export declare const CommandExecutionContext: InjectionToken<
|
|
28
|
+
CommanderExecutionContext,
|
|
29
|
+
undefined,
|
|
30
|
+
false
|
|
31
|
+
>
|
|
32
|
+
//# sourceMappingURL=execution-context.token.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-context.token.d.mts","sourceRoot":"","sources":["../../../src/tokens/execution-context.token.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"execution-context.token.d.mts","sourceRoot":"","sources":["../../../src/tokens/execution-context.token.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAIxE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,uBAAuB,6DAEnC,CAAA"}
|